-
Notifications
You must be signed in to change notification settings - Fork 0
Migrate Application Information View from XML to Compose #651
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
23f171e
Merge remote-tracking branch 'origin/develop' into layout/issue-650
DongJun-H e58ef53
Migrate Application Information View from XML to Compose
DongJun-H 7640a7b
Remove unnecessary resources
DongJun-H fa69143
Change chevron right icon
DongJun-H 7e1dad1
Improve structure and UI consistency
DongJun-H 620a873
Add exception handling (e.g. try-catch for PackageManager.NameNotFoun…
DongJun-H 69bc0a6
#651 [feature] Add overScrollMode in RuleScreen
yuni-ju File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
72 changes: 0 additions & 72 deletions
72
presentation/src/main/java/daily/dayo/presentation/fragment/policy/PolicyFragment.kt
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 0 additions & 70 deletions
70
...src/main/java/daily/dayo/presentation/fragment/setting/information/InformationFragment.kt
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 173 additions & 0 deletions
173
presentation/src/main/java/daily/dayo/presentation/screen/settings/AppInformationScreen.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| package daily.dayo.presentation.screen.settings | ||
|
|
||
| import android.content.Context | ||
| import android.content.pm.PackageManager | ||
| import android.os.Build | ||
| 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.fillMaxSize | ||
| 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.wrapContentSize | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.Scaffold | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.platform.LocalContext | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import daily.dayo.presentation.R | ||
| import daily.dayo.presentation.screen.rules.RuleType | ||
| import daily.dayo.presentation.theme.Dark | ||
| import daily.dayo.presentation.theme.DayoTheme | ||
| import daily.dayo.presentation.theme.Gray4_C5CAD2 | ||
| import daily.dayo.presentation.theme.Primary_23C882 | ||
| import daily.dayo.presentation.view.NoRippleIconButton | ||
| import daily.dayo.presentation.view.TopNavigation | ||
| import daily.dayo.presentation.view.TopNavigationAlign | ||
|
|
||
| @Composable | ||
| fun AppInformationScreen( | ||
| onBackClick: () -> Unit = {}, | ||
| onRulesClick: (RuleType) -> Unit = {}, | ||
| ) { | ||
| Scaffold( | ||
| topBar = { AppInformationTopBar(onBackClick = onBackClick) }, | ||
| ) { paddingValues -> | ||
| AppInformationContent( | ||
| modifier = Modifier.padding(paddingValues), | ||
| onRulesClick = onRulesClick, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| fun AppInformationTopBar( | ||
| onBackClick: () -> Unit, | ||
| ) { | ||
| TopNavigation( | ||
| leftIcon = { | ||
| NoRippleIconButton( | ||
| onClick = { onBackClick() }, | ||
| iconContentDescription = stringResource(R.string.back_sign), | ||
| iconPainter = painterResource(id = R.drawable.ic_arrow_left), | ||
| ) | ||
| }, | ||
| title = stringResource(R.string.information_title), | ||
| titleAlignment = TopNavigationAlign.CENTER | ||
| ) | ||
| } | ||
|
|
||
| @Composable | ||
| fun AppInformationContent( | ||
| modifier: Modifier = Modifier, | ||
| onRulesClick: (RuleType) -> Unit = {}, | ||
| ) { | ||
| val context = LocalContext.current | ||
| val appVersion = getAppVersion(context) | ||
|
|
||
| Column( | ||
| modifier = modifier | ||
| .fillMaxSize() | ||
| .padding(vertical = 8.dp, horizontal = 20.dp), | ||
| ) { | ||
| AppInformationItem( | ||
| title = stringResource(R.string.rules_terms_and_conditions), | ||
| onClick = { onRulesClick(RuleType.TERMS_AND_CONDITIONS) }, | ||
| ) | ||
| Spacer(modifier = Modifier.height(2.dp)) | ||
| AppInformationItem( | ||
| title = stringResource(R.string.rules_privacy_policy_title), | ||
| onClick = { onRulesClick(RuleType.PRIVACY_POLICY) }, | ||
| ) | ||
| Spacer(modifier = Modifier.height(2.dp)) | ||
| AppInformationItem( | ||
| title = stringResource(R.string.app_version), | ||
| description = "DAYO $appVersion", | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| fun AppInformationItem( | ||
| title: String, | ||
| description: String? = null, | ||
| onClick: () -> Unit = {}, | ||
| ) { | ||
| Row( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .height(48.dp) | ||
| .clickable { onClick() }, | ||
| verticalAlignment = Alignment.CenterVertically | ||
| ) { | ||
| Text( | ||
| text = title, | ||
| style = DayoTheme.typography.b4, | ||
| color = Dark, | ||
| ) | ||
| Spacer(modifier = Modifier.weight(1f)) | ||
| if (!description.isNullOrBlank()) { | ||
| Text( | ||
| text = description, | ||
| style = DayoTheme.typography.b4, | ||
| color = DayoTheme.colorScheme.primary, | ||
| modifier = Modifier | ||
| .padding(end = 4.dp) | ||
| .wrapContentSize(), | ||
| ) | ||
| } else { | ||
| Icon( | ||
| modifier = Modifier | ||
| .padding(end = 4.dp) | ||
| .size(20.dp), | ||
| painter = painterResource(id = R.drawable.ic_chevron_r), | ||
| contentDescription = null, | ||
| tint = DayoTheme.colorScheme.outline, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun getAppVersion(context: Context): String { | ||
| return try { | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | ||
| context.packageManager.getPackageInfo( | ||
| context.packageName, | ||
| PackageManager.PackageInfoFlags.of(0) | ||
| ).versionName | ||
| } else { | ||
| context.packageManager.getPackageInfo(context.packageName, 0).versionName | ||
| } ?: "" | ||
| } catch (e: PackageManager.NameNotFoundException) { | ||
| "" | ||
| } | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| fun PreviewAppInformationContent() { | ||
| DayoTheme { | ||
| AppInformationContent() | ||
| } | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| fun PreviewSettingsListItem() { | ||
| DayoTheme { | ||
| Column { | ||
| AppInformationItem(title = "이용약관") | ||
| AppInformationItem(title = "개인정보처리방침") | ||
| AppInformationItem(title = "앱 버전", description = "DAYO 1.0.0") | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.