diff --git a/app/build.gradle b/app/build.gradle index 32f56b1775..85164a4a98 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -153,6 +153,7 @@ dependencies { implementation project(':library-emojifier') implementation project(':library-syntax-highlighter') implementation project(':analytics') + implementation project(':ui-settings') def applicationDependencies = rootProject.ext.mainApplication def unitTestDependencies = rootProject.ext.unitTesting diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/settings/AboutAppDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/settings/AboutAppDI.kt index d99ce82bf0..c538a21000 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/settings/AboutAppDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/settings/AboutAppDI.kt @@ -6,8 +6,8 @@ import com.anytypeio.anytype.domain.auth.interactor.GetLibraryVersion import com.anytypeio.anytype.domain.auth.repo.AuthRepository import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.misc.UrlBuilder -import com.anytypeio.anytype.presentation.settings.AboutAppViewModel import com.anytypeio.anytype.ui.settings.AboutAppFragment +import com.anytypeio.anytype.ui_settings.about.AboutAppViewModel import dagger.Module import dagger.Provides import dagger.Subcomponent diff --git a/app/src/main/java/com/anytypeio/anytype/ui/settings/AboutAppFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/settings/AboutAppFragment.kt index de43359840..4a20531679 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/settings/AboutAppFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/settings/AboutAppFragment.kt @@ -4,33 +4,22 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.padding -import androidx.compose.material.Text +import androidx.compose.material.MaterialTheme import androidx.compose.material.Typography -import androidx.compose.runtime.Composable -import androidx.compose.runtime.collectAsState -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ViewCompositionStrategy -import androidx.compose.ui.res.colorResource -import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.Font import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.fragment.app.viewModels import com.anytypeio.anytype.BuildConfig import com.anytypeio.anytype.R -import com.anytypeio.anytype.core_ui.foundation.Dragger import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetComposeFragment import com.anytypeio.anytype.di.common.componentManager -import com.anytypeio.anytype.presentation.settings.AboutAppViewModel +import com.anytypeio.anytype.ui_settings.about.AboutAppScreen +import com.anytypeio.anytype.ui_settings.about.AboutAppViewModel import javax.inject.Inject @@ -48,7 +37,14 @@ class AboutAppFragment : BaseBottomSheetComposeFragment() { ): View { return ComposeView(requireContext()).apply { setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) - setContent { aboutAppScreen(vm) } + setContent { + MaterialTheme(typography = typography) { + AboutAppScreen( + vm = vm, + version = BuildConfig.VERSION_NAME + ) + } + } } } @@ -61,145 +57,6 @@ class AboutAppFragment : BaseBottomSheetComposeFragment() { } } -@Composable -fun aboutAppScreen( - vm: AboutAppViewModel -) { - - Column { - Box( - modifier = Modifier.padding(top = 6.dp).align(Alignment.CenterHorizontally) - ) { - Dragger() - } - Box( - modifier = Modifier.align(Alignment.CenterHorizontally).padding( - top = 75.dp, - bottom = 16.dp - ) - ) { - Text( - text = stringResource(R.string.about), - fontFamily = fonts, - fontWeight = FontWeight.Bold, - fontSize = 28.sp - ) - } - Row( - modifier = Modifier.padding( - start = 20.dp, - end = 20.dp, - top = 12.dp, - bottom = 12.dp - ) - ) { - Box(modifier = Modifier.weight(1.0f, true)) { - Text( - text = stringResource(R.string.app_version), - fontFamily = fonts, - fontSize = 17.sp, - color = colorResource(R.color.text_secondary) - ) - } - Box( - modifier = Modifier.weight(2.0f, true), - contentAlignment = Alignment.CenterEnd - ) { - Text( - text = BuildConfig.VERSION_NAME, - fontFamily = fonts, - fontSize = 17.sp, - color = colorResource(R.color.text_primary) - ) - } - } - Row( - modifier = Modifier.padding( - start = 20.dp, - end = 20.dp, - top = 12.dp, - bottom = 12.dp - ) - ) { - Box(modifier = Modifier.weight(1.0f, true)) { - Text( - text = stringResource(R.string.build_number), - fontFamily = fonts, - fontSize = 17.sp, - color = colorResource(R.color.text_secondary) - ) - } - Box( - modifier = Modifier.weight(2.0f, true), - contentAlignment = Alignment.CenterEnd - ) { - Text( - text = BuildConfig.VERSION_CODE.toString(), - fontFamily = fonts, - fontSize = 17.sp, - color = colorResource(R.color.text_primary) - ) - } - } - Row( - modifier = Modifier.padding( - start = 20.dp, - end = 20.dp, - top = 12.dp, - bottom = 12.dp - ) - ) { - Box(modifier = Modifier.weight(1.0f, true)) { - Text( - text = stringResource(R.string.library), - fontFamily = fonts, - fontSize = 17.sp, - color = colorResource(R.color.text_secondary) - ) - } - Box( - modifier = Modifier.weight(2.0f, true), - contentAlignment = Alignment.CenterEnd - ) { - Text( - text = vm.libraryVersion.collectAsState().value, - fontFamily = fonts, - fontSize = 17.sp, - color = colorResource(R.color.text_primary) - ) - } - } - Row( - modifier = Modifier.padding( - start = 20.dp, - end = 20.dp, - top = 12.dp, - bottom = 32.dp - ) - ) { - Box(modifier = Modifier.weight(1.0f, true)) { - Text( - text = stringResource(R.string.user_id), - fontFamily = fonts, - fontSize = 17.sp, - color = colorResource(R.color.text_secondary) - ) - } - Box( - modifier = Modifier.weight(2.0f, true), - contentAlignment = Alignment.CenterEnd - ) { - Text( - text = vm.userId.collectAsState().value, - fontFamily = fonts, - fontSize = 17.sp, - color = colorResource(R.color.text_primary) - ) - } - } - } -} - val fonts = FontFamily( Font(R.font.inter_regular), Font(R.font.inter_bold, weight = FontWeight.Bold), diff --git a/app/src/main/java/com/anytypeio/anytype/ui/settings/AccountAndDataFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/settings/AccountAndDataFragment.kt index a93d291b07..abe4c4c3f8 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/settings/AccountAndDataFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/settings/AccountAndDataFragment.kt @@ -4,26 +4,11 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.compose.foundation.Image -import androidx.compose.foundation.layout.* import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ViewCompositionStrategy -import androidx.compose.ui.res.colorResource -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import com.anytypeio.anytype.R -import com.anytypeio.anytype.core_ui.foundation.Divider -import com.anytypeio.anytype.core_ui.foundation.Dragger -import com.anytypeio.anytype.core_ui.foundation.Toolbar import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetComposeFragment +import com.anytypeio.anytype.ui_settings.account.AccountAndDataScreen class AccountAndDataFragment : BaseBottomSheetComposeFragment() { @@ -34,7 +19,11 @@ class AccountAndDataFragment : BaseBottomSheetComposeFragment() { ): View { return ComposeView(requireContext()).apply { setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) - setContent { accountAndDataScreen() } + setContent { + MaterialTheme(typography = typography) { + AccountAndDataScreen() + } + } } } @@ -47,151 +36,3 @@ class AccountAndDataFragment : BaseBottomSheetComposeFragment() { } } -@Composable -fun accountAndDataScreen() { - MaterialTheme(typography = typography) { - Column { - Box(Modifier.padding(vertical = 6.dp).align(Alignment.CenterHorizontally)) { - Dragger() - } - Toolbar(stringResource(R.string.account_and_data)) - Section(stringResource(R.string.access)) - Keychain() - Divider(paddingStart = 60.dp) - Pincode() - Divider(paddingStart = 60.dp) - Section(stringResource(R.string.data)) - Action(stringResource(R.string.clear_file_cache)) - Divider() - Section(stringResource(R.string.account)) - Action( - name = stringResource(R.string.reset_account), - color = colorResource(R.color.anytype_text_red) - ) - Divider() - Action( - name = stringResource(R.string.delete_account), - color = colorResource(R.color.anytype_text_red) - ) - Divider() - Box(Modifier.height(20.dp)) - Action(stringResource(R.string.log_out)) - Divider() - Box(Modifier.height(54.dp)) - } - } -} - -@Composable -fun Section(name: String) { - Box( - modifier = Modifier.height(52.dp).fillMaxWidth(), - contentAlignment = Alignment.BottomStart - ) { - Text( - text = name, - fontSize = 13.sp, - modifier = Modifier.padding( - start = 20.dp, - bottom = 8.dp - ), - color = colorResource(R.color.text_secondary) - ) - } -} - -@Composable -fun Keychain() { - Row( - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier.height(52.dp) - ) { - Image( - painterResource(R.drawable.ic_key), - contentDescription = "Key icon", - modifier = Modifier.padding( - start = 20.dp - ) - ) - Text( - text = stringResource(R.string.keychain_phrase), - modifier = Modifier.padding( - start = 12.dp - ) - ) - Box( - modifier = Modifier.weight(1.0f, true), - contentAlignment = Alignment.CenterEnd - ) { - Arrow() - } - } -} - -@Composable -fun Pincode() { - Row( - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier.height(52.dp) - ) { - Image( - painterResource(R.drawable.ic_pin_code), - contentDescription = "Pincode icon", - modifier = Modifier.padding( - start = 20.dp - ) - ) - Text( - text = stringResource(R.string.pin_code), - modifier = Modifier.padding( - start = 12.dp - ) - ) - Box( - modifier = Modifier.weight(1.0f, true), - contentAlignment = Alignment.CenterEnd - ) { - Row { - Text( - text = stringResource(R.string.off), - fontSize = 17.sp, - color = colorResource(R.color.text_secondary), - modifier = Modifier.padding(end = 10.dp) - ) - Arrow() - } - } - } -} - -@Composable -fun Arrow() { - Image( - painterResource(R.drawable.ic_arrow_forward), - contentDescription = "Arrow forward", - modifier = Modifier.padding( - end = 20.dp - ) - ) -} - -@Composable -fun Action( - name: String, - color: Color = Color.Unspecified -) { - Box( - modifier = Modifier.height(52.dp).fillMaxWidth(), - contentAlignment = Alignment.CenterStart - ) { - Text( - text = name, - color = color, - fontSize = 17.sp, - modifier = Modifier.padding( - start = 20.dp - ) - ) - } -} - diff --git a/app/src/main/java/com/anytypeio/anytype/ui/settings/MainSettingFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/settings/MainSettingFragment.kt new file mode 100644 index 0000000000..a391da7ddc --- /dev/null +++ b/app/src/main/java/com/anytypeio/anytype/ui/settings/MainSettingFragment.kt @@ -0,0 +1,32 @@ +package com.anytypeio.anytype.ui.settings + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.compose.material.MaterialTheme +import androidx.compose.ui.platform.ComposeView +import androidx.compose.ui.platform.ViewCompositionStrategy +import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetComposeFragment +import com.anytypeio.anytype.ui_settings.main.MainSettingScreen + +class MainSettingFragment : BaseBottomSheetComposeFragment() { + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + return ComposeView(requireContext()).apply { + setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) + setContent { + MaterialTheme(typography = typography) { + MainSettingScreen() + } + } + } + } + + override fun injectDependencies() {} + override fun releaseDependencies() {} +} \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2d3dda91ef..176be58c46 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -263,16 +263,4 @@ Do the computation of an expensive paragraph of text on a background thread: All files will be deleted from your current device. They can be downloaded again from a backup node or another device. new profile - About - App version - Library - User ID - Build Number - - Access - Data - Account - Delete account - Reset account - Clear file cache diff --git a/core-ui/build.gradle b/core-ui/build.gradle index 1d75f4c6f1..166830d41e 100644 --- a/core-ui/build.gradle +++ b/core-ui/build.gradle @@ -13,43 +13,6 @@ android { testInstrumentationRunner config["test_runner"] } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - - flavorDimensions 'default' - productFlavors { - stable { - dimension 'default' - } - experimental{ - dimension 'default' - } - } - - sourceSets { - stable { - java { - srcDirs 'src/stable/java' - } - res { - srcDirs 'src/stable/res' - } - } - experimental { - java { - srcDirs 'src/experimental/java' - } - res { - srcDirs 'src/experimental/res' - } - } - } - testOptions { unitTests { includeAndroidResources = true diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/foundation/Foundation.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/foundation/Foundation.kt index df128aa7d4..c7251f7d8b 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/foundation/Foundation.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/foundation/Foundation.kt @@ -1,5 +1,7 @@ package com.anytypeio.anytype.core_ui.foundation +import androidx.annotation.DrawableRes +import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.RoundedCornerShape @@ -9,6 +11,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.colorResource +import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.anytypeio.anytype.core_ui.R @@ -21,7 +24,8 @@ fun Toolbar(title: String) { ) { Text( text = title, - style = MaterialTheme.typography.h3 + style = MaterialTheme.typography.h3, + color = colorResource(R.color.text_primary) ) } } @@ -50,4 +54,47 @@ fun Divider( .height(0.5.dp) .fillMaxWidth() ) +} + +@Composable +fun Option( + @DrawableRes image: Int, + text: String +) { + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.height(52.dp) + ) { + Image( + painterResource(image), + contentDescription = "Option icon", + modifier = Modifier.padding( + start = 20.dp + ) + ) + Text( + text = text, + color = colorResource(R.color.text_primary), + modifier = Modifier.padding( + start = 12.dp + ) + ) + Box( + modifier = Modifier.weight(1.0f, true), + contentAlignment = Alignment.CenterEnd + ) { + Arrow() + } + } +} + +@Composable +fun Arrow() { + Image( + painterResource(R.drawable.ic_arrow_forward), + contentDescription = "Arrow forward", + modifier = Modifier.padding( + end = 20.dp + ) + ) } \ No newline at end of file diff --git a/library-page-icon-picker-widget/build.gradle b/library-page-icon-picker-widget/build.gradle index 73813a98bf..c97c739c62 100644 --- a/library-page-icon-picker-widget/build.gradle +++ b/library-page-icon-picker-widget/build.gradle @@ -13,48 +13,6 @@ android { testInstrumentationRunner config["test_runner"] } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - - flavorDimensions 'default' - productFlavors { - stable { - dimension 'default' - } - experimental{ - dimension 'default' - } - } - - sourceSets { - stable { - java { - srcDirs 'src/stable/java' - } - res { - srcDirs 'src/stable/res' - } - } - experimental { - java { - srcDirs 'src/experimental/java' - } - res { - srcDirs 'src/experimental/res' - } - } - } - - testOptions { - unitTests { - includeAndroidResources = true - } - } - compileOptions { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 diff --git a/library-page-icon-picker-widget/consumer-rules.pro b/library-page-icon-picker-widget/consumer-rules.pro deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/library-page-icon-picker-widget/proguard-rules.pro b/library-page-icon-picker-widget/proguard-rules.pro deleted file mode 100644 index f1b424510d..0000000000 --- a/library-page-icon-picker-widget/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile diff --git a/presentation/build.gradle b/presentation/build.gradle index 5cbed8a9fc..a6a0f89a94 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -15,42 +15,12 @@ android { testOptions.unitTests.includeAndroidResources = true - flavorDimensions 'default' - productFlavors { - stable { - dimension 'default' - } - experimental{ - dimension 'default' - } - } - - sourceSets { - stable { - java { - srcDirs 'src/stable/java' - } - res { - srcDirs 'src/stable/res' - } - } - experimental { - java { - srcDirs 'src/experimental/java' - } - res { - srcDirs 'src/experimental/res' - } - } - } - lint { disable 'NullSafeMutableLiveData' } } dependencies { - implementation project(':domain') implementation project(':core-utils') implementation project(':library-emojifier') diff --git a/protocol/build.gradle b/protocol/build.gradle index f4f21abea1..66fd978f5d 100644 --- a/protocol/build.gradle +++ b/protocol/build.gradle @@ -14,13 +14,6 @@ android { testInstrumentationRunner config["test_runner"] } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 diff --git a/settings.gradle b/settings.gradle index 32ee4ae4fa..17743991a2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,3 +15,4 @@ include ':app', ':analytics', ':protocol', ':core-models' +include ':ui-settings' diff --git a/ui-settings/.gitignore b/ui-settings/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/ui-settings/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/ui-settings/build.gradle b/ui-settings/build.gradle new file mode 100644 index 0000000000..f800f2f9e9 --- /dev/null +++ b/ui-settings/build.gradle @@ -0,0 +1,49 @@ +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' + +android { + def config = rootProject.extensions.getByName("ext") + + compileSdkVersion config["compile_sdk"] + + defaultConfig { + minSdkVersion config["min_sdk"] + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_11 + } + + buildFeatures { + compose true + } + + composeOptions { + kotlinCompilerExtensionVersion config["compose_version"] + } +} + +dependencies { + implementation project(':domain') + implementation project(':core-ui') + + def applicationDependencies = rootProject.ext.mainApplication + def unitTestDependencies = rootProject.ext.unitTesting + + implementation applicationDependencies.lifecycleViewModel + + implementation applicationDependencies.compose + implementation applicationDependencies.composeFoundation + implementation applicationDependencies.composeMaterial + implementation applicationDependencies.composeToolingPreview + + debugImplementation applicationDependencies.composeTooling + + testImplementation unitTestDependencies.junit + testImplementation unitTestDependencies.kotlinTest +} \ No newline at end of file diff --git a/ui-settings/src/main/AndroidManifest.xml b/ui-settings/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..fa597c9982 --- /dev/null +++ b/ui-settings/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/about/AboutAppScreen.kt b/ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/about/AboutAppScreen.kt new file mode 100644 index 0000000000..e352c7213d --- /dev/null +++ b/ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/about/AboutAppScreen.kt @@ -0,0 +1,123 @@ +package com.anytypeio.anytype.ui_settings.about + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.padding +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.colorResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.anytypeio.anytype.core_ui.foundation.Dragger +import com.anytypeio.anytype.ui_settings.R + +@Composable +fun AboutAppScreen( + vm: AboutAppViewModel, + version: String +) { + Column { + Box( + modifier = Modifier.padding(top = 6.dp).align(Alignment.CenterHorizontally) + ) { + Dragger() + } + Box( + modifier = Modifier.align(Alignment.CenterHorizontally).padding( + top = 75.dp, + bottom = 16.dp + ) + ) { + Text( + text = stringResource(R.string.about), + fontWeight = FontWeight.Bold, + fontSize = 28.sp, + color = colorResource(R.color.text_primary) + ) + } + Row( + modifier = Modifier.padding( + start = 20.dp, + end = 20.dp, + top = 12.dp, + bottom = 12.dp + ) + ) { + Box(modifier = Modifier.weight(1.0f, true)) { + Text( + text = stringResource(R.string.app_version), + fontSize = 17.sp, + color = colorResource(R.color.text_secondary) + ) + } + Box( + modifier = Modifier.weight(2.0f, true), + contentAlignment = Alignment.CenterEnd + ) { + Text( + text = version, + fontSize = 17.sp, + color = colorResource(R.color.text_primary) + ) + } + } + Row( + modifier = Modifier.padding( + start = 20.dp, + end = 20.dp, + top = 12.dp, + bottom = 12.dp + ) + ) { + Box(modifier = Modifier.weight(1.0f, true)) { + Text( + text = stringResource(R.string.library), + fontSize = 17.sp, + color = colorResource(R.color.text_secondary) + ) + } + Box( + modifier = Modifier.weight(2.0f, true), + contentAlignment = Alignment.CenterEnd + ) { + Text( + text = vm.libraryVersion.collectAsState().value, + fontSize = 17.sp, + color = colorResource(R.color.text_primary) + ) + } + } + Row( + modifier = Modifier.padding( + start = 20.dp, + end = 20.dp, + top = 12.dp, + bottom = 32.dp + ) + ) { + Box(modifier = Modifier.weight(1.0f, true)) { + Text( + text = stringResource(R.string.user_id), + fontSize = 17.sp, + color = colorResource(R.color.text_secondary) + ) + } + Box( + modifier = Modifier.weight(2.0f, true), + contentAlignment = Alignment.CenterEnd + ) { + Text( + text = vm.userId.collectAsState().value, + fontSize = 17.sp, + color = colorResource(R.color.text_primary) + ) + } + } + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/settings/AboutAppViewModel.kt b/ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/about/AboutAppViewModel.kt similarity index 89% rename from presentation/src/main/java/com/anytypeio/anytype/presentation/settings/AboutAppViewModel.kt rename to ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/about/AboutAppViewModel.kt index 6815e61918..7372d4d193 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/settings/AboutAppViewModel.kt +++ b/ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/about/AboutAppViewModel.kt @@ -1,4 +1,4 @@ -package com.anytypeio.anytype.presentation.settings +package com.anytypeio.anytype.ui_settings.about import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider @@ -6,17 +6,16 @@ import androidx.lifecycle.viewModelScope import com.anytypeio.anytype.domain.auth.interactor.GetCurrentAccount import com.anytypeio.anytype.domain.auth.interactor.GetLibraryVersion import com.anytypeio.anytype.domain.base.BaseUseCase -import com.anytypeio.anytype.presentation.common.BaseViewModel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch class AboutAppViewModel( private val getCurrentAccount: GetCurrentAccount, private val getLibraryVersion: GetLibraryVersion -) : BaseViewModel() { +) : ViewModel() { val libraryVersion = MutableStateFlow("") - val userId = MutableStateFlow("") + val userId = MutableStateFlow("") init { viewModelScope.launch { diff --git a/ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/account/AccountAndDataScreen.kt b/ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/account/AccountAndDataScreen.kt new file mode 100644 index 0000000000..447c958a74 --- /dev/null +++ b/ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/account/AccountAndDataScreen.kt @@ -0,0 +1,133 @@ +package com.anytypeio.anytype.ui_settings.account + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.* +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.colorResource +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.anytypeio.anytype.core_ui.foundation.* +import com.anytypeio.anytype.ui_settings.R + +@Composable +fun AccountAndDataScreen() { + Column { + Box(Modifier.padding(vertical = 6.dp).align(Alignment.CenterHorizontally)) { + Dragger() + } + Toolbar(stringResource(R.string.account_and_data)) + Section(stringResource(R.string.access)) + Option( + image = R.drawable.ic_key, + text = stringResource(R.string.keychain_phrase) + ) + Divider(paddingStart = 60.dp) + Pincode() + Divider(paddingStart = 60.dp) + Section(stringResource(R.string.data)) + Action( + name = stringResource(R.string.clear_file_cache), + color = colorResource(R.color.text_primary) + ) + Divider() + Section(stringResource(R.string.account)) + Action( + name = stringResource(R.string.reset_account), + color = colorResource(R.color.anytype_text_red) + ) + Divider() + Action( + name = stringResource(R.string.delete_account), + color = colorResource(R.color.anytype_text_red) + ) + Divider() + Box(Modifier.height(20.dp)) + Action( + name = stringResource(R.string.log_out), + color = colorResource(R.color.text_primary) + ) + Divider() + Box(Modifier.height(54.dp)) + } +} + +@Composable +fun Section(name: String) { + Box( + modifier = Modifier.height(52.dp).fillMaxWidth(), + contentAlignment = Alignment.BottomStart + ) { + Text( + text = name, + fontSize = 13.sp, + modifier = Modifier.padding( + start = 20.dp, + bottom = 8.dp + ), + color = colorResource(R.color.text_secondary) + ) + } +} + +@Composable +fun Pincode() { + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.height(52.dp) + ) { + Image( + painterResource(R.drawable.ic_pin_code), + contentDescription = "Pincode icon", + modifier = Modifier.padding( + start = 20.dp + ) + ) + Text( + text = stringResource(R.string.pin_code), + color = colorResource(R.color.text_primary), + modifier = Modifier.padding( + start = 12.dp + ) + ) + Box( + modifier = Modifier.weight(1.0f, true), + contentAlignment = Alignment.CenterEnd + ) { + Row { + Text( + text = stringResource(R.string.off), + fontSize = 17.sp, + color = colorResource(R.color.text_secondary), + modifier = Modifier.padding(end = 10.dp) + ) + Arrow() + } + } + } +} + +@Composable +fun Action( + name: String, + color: Color = Color.Unspecified +) { + Box( + modifier = Modifier.height(52.dp).fillMaxWidth(), + contentAlignment = Alignment.CenterStart + ) { + Text( + text = name, + color = color, + fontSize = 17.sp, + modifier = Modifier.padding( + start = 20.dp + ) + ) + } +} \ No newline at end of file diff --git a/ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/main/MainSettingScreen.kt b/ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/main/MainSettingScreen.kt new file mode 100644 index 0000000000..3bbc4fd6de --- /dev/null +++ b/ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/main/MainSettingScreen.kt @@ -0,0 +1,47 @@ +package com.anytypeio.anytype.ui_settings.main + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import com.anytypeio.anytype.core_ui.foundation.Divider +import com.anytypeio.anytype.core_ui.foundation.Dragger +import com.anytypeio.anytype.core_ui.foundation.Option +import com.anytypeio.anytype.ui_settings.R + +@Composable +fun MainSettingScreen() { + Column { + Box( + modifier = Modifier.padding(vertical = 6.dp).align(Alignment.CenterHorizontally) + ) { + Dragger() + } + Option( + image = R.drawable.ic_key, + text = stringResource(R.string.account_and_data) + ) + Divider() + Option( + image = R.drawable.ic_key, + text = stringResource(R.string.personalization) + ) + Divider() + Option( + image = R.drawable.ic_key, + text = stringResource(R.string.appearance) + ) + Divider() + Option( + image = R.drawable.ic_key, + text = stringResource(R.string.about) + ) + Divider() + Box(modifier = Modifier.height(16.dp)) + } +} \ No newline at end of file diff --git a/ui-settings/src/main/res/drawable/ic_key.xml b/ui-settings/src/main/res/drawable/ic_key.xml new file mode 100644 index 0000000000..9e2698ce5d --- /dev/null +++ b/ui-settings/src/main/res/drawable/ic_key.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/ui-settings/src/main/res/drawable/ic_pin_code.xml b/ui-settings/src/main/res/drawable/ic_pin_code.xml new file mode 100644 index 0000000000..e3d196f31e --- /dev/null +++ b/ui-settings/src/main/res/drawable/ic_pin_code.xml @@ -0,0 +1,17 @@ + + + + + diff --git a/ui-settings/src/main/res/values/strings.xml b/ui-settings/src/main/res/values/strings.xml new file mode 100644 index 0000000000..0ac00675c8 --- /dev/null +++ b/ui-settings/src/main/res/values/strings.xml @@ -0,0 +1,19 @@ + + + About + App version + Library + User ID + + Personalization + Appearance + Keychain phrase + Clear file cache + Account + Reset account + Delete account + Data + Logout + Pin code + Access + \ No newline at end of file