-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Taewan-P/feat/about-page
Add about page & license page
- Loading branch information
Showing
18 changed files
with
387 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
180 changes: 180 additions & 0 deletions
180
app/src/main/kotlin/dev/chungjungsoo/gptmobile/presentation/ui/setting/AboutScreen.kt
This file contains 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,180 @@ | ||
package dev.chungjungsoo.gptmobile.presentation.ui.setting | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.rememberScrollState | ||
import androidx.compose.foundation.verticalScroll | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.automirrored.filled.ArrowBack | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.LargeTopAppBar | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TopAppBarDefaults | ||
import androidx.compose.material3.TopAppBarScrollBehavior | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.input.nestedscroll.nestedScroll | ||
import androidx.compose.ui.platform.LocalClipboardManager | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.platform.LocalUriHandler | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.res.vectorResource | ||
import androidx.compose.ui.text.AnnotatedString | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import androidx.compose.ui.unit.dp | ||
import dev.chungjungsoo.gptmobile.R | ||
import dev.chungjungsoo.gptmobile.presentation.common.SettingItem | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun AboutScreen( | ||
onNavigationClick: () -> Unit, | ||
onNavigationToLicense: () -> Unit | ||
) { | ||
val scrollState = rememberScrollState() | ||
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior() | ||
val context = LocalContext.current | ||
val version = context.packageManager.getPackageInfo(context.packageName, 0).versionName | ||
val clipboardManager = LocalClipboardManager.current | ||
val uriHandler = LocalUriHandler.current | ||
val githubLink = stringResource(R.string.github_link) | ||
val fdroidLink = stringResource(R.string.f_droid_link) | ||
val googlePlayLink = stringResource(R.string.play_store_link) | ||
val feedbackLink = stringResource(R.string.feedback_link) | ||
|
||
Scaffold( | ||
modifier = Modifier | ||
.nestedScroll(scrollBehavior.nestedScrollConnection), | ||
topBar = { | ||
AboutTopAppBar( | ||
scrollBehavior = scrollBehavior, | ||
navigationOnClick = onNavigationClick | ||
) | ||
} | ||
) { innerPadding -> | ||
Column( | ||
modifier = Modifier | ||
.padding(innerPadding) | ||
.verticalScroll(scrollState) | ||
) { | ||
SettingItem( | ||
modifier = Modifier.height(64.dp), | ||
title = stringResource(R.string.version), | ||
description = "v$version", | ||
onItemClick = { clipboardManager.setText(AnnotatedString("v$version")) }, | ||
showTrailingIcon = false, | ||
showLeadingIcon = true, | ||
leadingIcon = { | ||
Icon( | ||
ImageVector.vectorResource(id = R.drawable.ic_info), | ||
contentDescription = stringResource(R.string.version_icon) | ||
) | ||
} | ||
) | ||
SettingItem( | ||
modifier = Modifier.height(64.dp), | ||
title = stringResource(R.string.license), | ||
description = stringResource(R.string.license_description), | ||
onItemClick = onNavigationToLicense, | ||
showTrailingIcon = true, | ||
showLeadingIcon = true, | ||
leadingIcon = { | ||
Icon( | ||
ImageVector.vectorResource(id = R.drawable.ic_license), | ||
contentDescription = stringResource(R.string.license_icon) | ||
) | ||
} | ||
) | ||
SettingItem( | ||
modifier = Modifier.height(64.dp), | ||
title = stringResource(R.string.github), | ||
onItemClick = { uriHandler.openUri(githubLink) }, | ||
showTrailingIcon = false, | ||
showLeadingIcon = true, | ||
leadingIcon = { | ||
Icon( | ||
ImageVector.vectorResource(id = R.drawable.ic_github), | ||
contentDescription = stringResource(R.string.github_icon) | ||
) | ||
} | ||
) | ||
SettingItem( | ||
modifier = Modifier.height(64.dp), | ||
title = stringResource(R.string.f_droid), | ||
onItemClick = { uriHandler.openUri(fdroidLink) }, | ||
showTrailingIcon = false, | ||
showLeadingIcon = true, | ||
leadingIcon = { | ||
Icon( | ||
ImageVector.vectorResource(id = R.drawable.ic_f_droid), | ||
contentDescription = stringResource(R.string.f_droid_icon) | ||
) | ||
} | ||
) | ||
SettingItem( | ||
modifier = Modifier.height(64.dp), | ||
title = stringResource(R.string.play_store), | ||
onItemClick = { uriHandler.openUri(googlePlayLink) }, | ||
showTrailingIcon = false, | ||
showLeadingIcon = true, | ||
leadingIcon = { | ||
Icon( | ||
ImageVector.vectorResource(id = R.drawable.ic_play_store), | ||
contentDescription = stringResource(R.string.play_store_icon) | ||
) | ||
} | ||
) | ||
SettingItem( | ||
modifier = Modifier.height(64.dp), | ||
title = stringResource(R.string.feedback), | ||
description = stringResource(R.string.feedback_description), | ||
onItemClick = { uriHandler.openUri(feedbackLink) }, | ||
showTrailingIcon = false, | ||
showLeadingIcon = true, | ||
leadingIcon = { | ||
Icon( | ||
ImageVector.vectorResource(id = R.drawable.ic_feedback), | ||
contentDescription = stringResource(R.string.feedback_icon) | ||
) | ||
} | ||
) | ||
} | ||
} | ||
} | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun AboutTopAppBar( | ||
scrollBehavior: TopAppBarScrollBehavior, | ||
navigationOnClick: () -> Unit | ||
) { | ||
LargeTopAppBar( | ||
colors = TopAppBarDefaults.topAppBarColors( | ||
containerColor = MaterialTheme.colorScheme.background, | ||
titleContentColor = MaterialTheme.colorScheme.onBackground | ||
), | ||
title = { | ||
Text( | ||
modifier = Modifier.padding(4.dp), | ||
text = stringResource(R.string.about), | ||
maxLines = 1, | ||
overflow = TextOverflow.Ellipsis | ||
) | ||
}, | ||
navigationIcon = { | ||
IconButton( | ||
modifier = Modifier.padding(4.dp), | ||
onClick = navigationOnClick | ||
) { | ||
Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(R.string.go_back)) | ||
} | ||
}, | ||
scrollBehavior = scrollBehavior | ||
) | ||
} |
77 changes: 77 additions & 0 deletions
77
app/src/main/kotlin/dev/chungjungsoo/gptmobile/presentation/ui/setting/LicenseScreen.kt
This file contains 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,77 @@ | ||
package dev.chungjungsoo.gptmobile.presentation.ui.setting | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.automirrored.filled.ArrowBack | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.LargeTopAppBar | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TopAppBarDefaults | ||
import androidx.compose.material3.TopAppBarScrollBehavior | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.input.nestedscroll.nestedScroll | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import androidx.compose.ui.unit.dp | ||
import com.mikepenz.aboutlibraries.ui.compose.m3.LibrariesContainer | ||
import dev.chungjungsoo.gptmobile.R | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun LicenseScreen( | ||
onNavigationClick: () -> Unit | ||
) { | ||
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior() | ||
|
||
Scaffold( | ||
modifier = Modifier | ||
.nestedScroll(scrollBehavior.nestedScrollConnection), | ||
topBar = { | ||
LicenseTopAppBar(onNavigationClick, scrollBehavior) | ||
} | ||
) { innerPadding -> | ||
Column( | ||
modifier = Modifier.padding(innerPadding) | ||
) { | ||
LibrariesContainer(modifier = Modifier.fillMaxSize()) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
@OptIn(ExperimentalMaterial3Api::class) | ||
private fun LicenseTopAppBar( | ||
onNavigationClick: () -> Unit, | ||
scrollBehavior: TopAppBarScrollBehavior | ||
) { | ||
LargeTopAppBar( | ||
colors = TopAppBarDefaults.topAppBarColors( | ||
containerColor = MaterialTheme.colorScheme.background, | ||
titleContentColor = MaterialTheme.colorScheme.onBackground | ||
), | ||
title = { | ||
Text( | ||
modifier = Modifier.padding(4.dp), | ||
text = stringResource(R.string.license), | ||
maxLines = 1, | ||
overflow = TextOverflow.Ellipsis | ||
) | ||
}, | ||
navigationIcon = { | ||
IconButton( | ||
modifier = Modifier.padding(4.dp), | ||
onClick = onNavigationClick | ||
) { | ||
Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(R.string.go_back)) | ||
} | ||
}, | ||
scrollBehavior = scrollBehavior | ||
) | ||
} |
This file contains 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
Oops, something went wrong.