-
Notifications
You must be signed in to change notification settings - Fork 140
Migrate HomeScreen, SyncStatus, and OfflineAreas to Compose #3476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
097aea4
129dad1
a666f54
8f3f55e
bbaa5a0
7b35e37
ff36935
781bc84
5fe65d3
b8842b4
7278aea
cb4ab00
8ec6da5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,208 @@ | ||||||||
| package org.groundplatform.android.ui.home | ||||||||
|
|
||||||||
| import androidx.compose.foundation.Image | ||||||||
| import androidx.compose.foundation.background | ||||||||
| import androidx.compose.foundation.clickable | ||||||||
| import androidx.compose.foundation.layout.Column | ||||||||
| import androidx.compose.foundation.layout.Row | ||||||||
| import androidx.compose.foundation.layout.Spacer | ||||||||
| import androidx.compose.foundation.layout.fillMaxWidth | ||||||||
| import androidx.compose.foundation.layout.height | ||||||||
| import androidx.compose.foundation.layout.padding | ||||||||
| import androidx.compose.foundation.layout.size | ||||||||
| import androidx.compose.foundation.layout.width | ||||||||
| import androidx.compose.foundation.rememberScrollState | ||||||||
| import androidx.compose.foundation.shape.CircleShape | ||||||||
| import androidx.compose.foundation.verticalScroll | ||||||||
| import androidx.compose.material.icons.Icons | ||||||||
| import androidx.compose.material.icons.automirrored.filled.ExitToApp | ||||||||
| import androidx.compose.material.icons.filled.Settings | ||||||||
| import androidx.compose.material3.Divider | ||||||||
| import androidx.compose.material3.HorizontalDivider | ||||||||
| import androidx.compose.material3.Icon | ||||||||
| import androidx.compose.material3.MaterialTheme | ||||||||
| import androidx.compose.material3.NavigationDrawerItem | ||||||||
| import androidx.compose.material3.NavigationDrawerItemDefaults | ||||||||
| import androidx.compose.material3.Text | ||||||||
| import androidx.compose.runtime.Composable | ||||||||
| import androidx.compose.ui.Alignment | ||||||||
| import androidx.compose.ui.Modifier | ||||||||
| import androidx.compose.ui.draw.clip | ||||||||
| import androidx.compose.ui.graphics.Color | ||||||||
|
|
||||||||
| import androidx.compose.ui.res.painterResource | ||||||||
| import androidx.compose.ui.res.stringResource | ||||||||
| import androidx.compose.ui.text.font.FontWeight | ||||||||
| import androidx.compose.ui.text.style.TextOverflow | ||||||||
| import androidx.compose.ui.unit.dp | ||||||||
| import androidx.compose.ui.unit.sp | ||||||||
| import org.groundplatform.android.R | ||||||||
| import org.groundplatform.android.model.Survey | ||||||||
| import org.groundplatform.android.model.User | ||||||||
|
|
||||||||
| @Composable | ||||||||
| fun HomeDrawer( | ||||||||
| user: User?, | ||||||||
| survey: Survey?, | ||||||||
| onSwitchSurvey: () -> Unit, | ||||||||
| onNavigateToOfflineAreas: () -> Unit, | ||||||||
| onNavigateToSyncStatus: () -> Unit, | ||||||||
| onNavigateToSettings: () -> Unit, | ||||||||
| onNavigateToAbout: () -> Unit, | ||||||||
| onNavigateToTerms: () -> Unit, | ||||||||
| onSignOut: () -> Unit, | ||||||||
| offlineAreasEnabled: Boolean = true | ||||||||
| ) { | ||||||||
| Column( | ||||||||
| modifier = Modifier | ||||||||
| .fillMaxWidth() | ||||||||
| .verticalScroll(rememberScrollState()) | ||||||||
| ) { | ||||||||
| // App Info Header | ||||||||
| Column( | ||||||||
| modifier = Modifier | ||||||||
| .fillMaxWidth() | ||||||||
| .background(MaterialTheme.colorScheme.surfaceVariant) | ||||||||
| .padding(vertical = 24.dp, horizontal = 16.dp) | ||||||||
| ) { | ||||||||
| Row( | ||||||||
| verticalAlignment = Alignment.CenterVertically, | ||||||||
| modifier = Modifier.fillMaxWidth() | ||||||||
| ) { | ||||||||
| Image( | ||||||||
| painter = painterResource(R.drawable.ground_logo), | ||||||||
| contentDescription = null, | ||||||||
| modifier = Modifier.size(24.dp) | ||||||||
| ) | ||||||||
| Spacer(Modifier.width(8.dp)) | ||||||||
| Column(modifier = Modifier.weight(1f)) { | ||||||||
| Text( | ||||||||
| text = stringResource(R.string.app_name), | ||||||||
| fontSize = 18.sp, | ||||||||
| fontWeight = FontWeight.Medium | ||||||||
| ) | ||||||||
| } | ||||||||
| if (user?.photoUrl != null) { | ||||||||
| androidx.compose.ui.viewinterop.AndroidView( | ||||||||
| factory = { context -> | ||||||||
| android.widget.ImageView(context).apply { | ||||||||
| scaleType = android.widget.ImageView.ScaleType.CENTER_CROP | ||||||||
| } | ||||||||
| }, | ||||||||
| update = { imageView -> | ||||||||
| com.bumptech.glide.Glide.with(imageView) | ||||||||
| .load(user.photoUrl) | ||||||||
| .circleCrop() | ||||||||
| .into(imageView) | ||||||||
| }, | ||||||||
| modifier = Modifier | ||||||||
| .size(32.dp) | ||||||||
| .clip(CircleShape) | ||||||||
| ) | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| // Survey Info | ||||||||
| Column( | ||||||||
| modifier = Modifier | ||||||||
| .fillMaxWidth() | ||||||||
| .padding(16.dp) | ||||||||
| ) { | ||||||||
| Row(verticalAlignment = Alignment.CenterVertically) { | ||||||||
| Icon( | ||||||||
| painter = painterResource(R.drawable.ic_content_paste), // Ensure this drawable exists or use Vector | ||||||||
| contentDescription = null, // stringResource(R.string.current_survey) | ||||||||
|
||||||||
| painter = painterResource(R.drawable.ic_content_paste), // Ensure this drawable exists or use Vector | |
| contentDescription = null, // stringResource(R.string.current_survey) | |
| contentDescription = stringResource(R.string.current_survey), |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contentDescription for this Icon is set to null. This is an accessibility issue. Please provide a meaningful string resource for the contentDescription that describes the 'Offline map imagery' icon.
| icon = { Icon(painterResource(R.drawable.ic_offline_pin), contentDescription = null) }, | |
| icon = { Icon(painterResource(R.drawable.ic_offline_pin), contentDescription = stringResource(R.string.offline_map_imagery)) }, |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contentDescription for this Icon is set to null. This is an accessibility issue. Please provide a meaningful string resource for the contentDescription that describes the 'Sync status' icon.
| icon = { Icon(painterResource(R.drawable.ic_sync), contentDescription = null) }, | |
| icon = { Icon(painterResource(R.drawable.ic_sync), contentDescription = stringResource(R.string.sync_status)) }, |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contentDescription for this Icon is set to null. This is an accessibility issue. Please provide a meaningful string resource for the contentDescription that describes the 'Settings' icon.
| icon = { Icon(Icons.Default.Settings, contentDescription = null) }, | |
| icon = { Icon(Icons.Default.Settings, contentDescription = stringResource(R.string.settings)) }, |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contentDescription for this Icon is set to null. This is an accessibility issue. Please provide a meaningful string resource for the contentDescription that describes the 'About' icon.
| icon = { Icon(painterResource(R.drawable.info_outline), contentDescription = null) }, | |
| icon = { Icon(painterResource(R.drawable.info_outline), contentDescription = stringResource(R.string.about)) }, |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contentDescription for this Icon is set to null. This is an accessibility issue. Please provide a meaningful string resource for the contentDescription that describes the 'Terms of service' icon.
| icon = { Icon(painterResource(R.drawable.feed), contentDescription = null) }, | |
| icon = { Icon(painterResource(R.drawable.feed), contentDescription = stringResource(R.string.terms_of_service)) }, |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contentDescription for this Icon is set to null. This is an accessibility issue. Please provide a meaningful string resource for the contentDescription that describes the 'Sign out' icon.
| icon = { Icon(Icons.AutoMirrored.Filled.ExitToApp, contentDescription = null) }, | |
| icon = { Icon(Icons.AutoMirrored.Filled.ExitToApp, contentDescription = stringResource(R.string.sign_out)) }, |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package org.groundplatform.android.ui.home | ||
|
|
||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.material3.DrawerState | ||
| import androidx.compose.material3.ModalDrawerSheet | ||
| import androidx.compose.material3.ModalNavigationDrawer | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
|
|
||
| @Composable | ||
| fun HomeScreen( | ||
| drawerState: DrawerState, | ||
| drawerContent: @Composable () -> Unit, | ||
| content: @Composable () -> Unit | ||
| ) { | ||
| ModalNavigationDrawer( | ||
| drawerState = drawerState, | ||
| drawerContent = { | ||
| ModalDrawerSheet { | ||
| drawerContent() | ||
| } | ||
| }, | ||
| content = content | ||
| ) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Dividerimport is not used in this file. Please remove unused imports to keep the codebase clean.