Skip to content

Commit

Permalink
Made some UI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aritra-tech committed Mar 25, 2024
1 parent b57376b commit 1fad4a7
Showing 1 changed file with 140 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,26 @@ import android.content.Intent
import android.net.Uri
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
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.widthIn
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
Expand All @@ -34,6 +41,7 @@ import com.aritra.notify.components.actions.SettingsComponent
import com.aritra.notify.components.actions.SettingsSwitchCard
import com.aritra.notify.navigation.NotifyScreens
import com.aritra.notify.ui.screens.MainActivity
import com.aritra.notify.ui.theme.PrimaryContainerLight
import com.aritra.notify.utils.Const
import com.aritra.notify.utils.shareApp
import com.aritra.notify.viewmodel.ThemeViewModel
Expand Down Expand Up @@ -64,11 +72,12 @@ fun SettingsScreen(controller: NavController) {
.fillMaxSize()
.padding(16.dp)
.verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Column {
Text(
text = "Settings",
text = stringResource(id = R.string.settings),
style = TextStyle(
fontSize = 28.sp,
fontWeight = FontWeight.Light,
Expand All @@ -78,122 +87,137 @@ fun SettingsScreen(controller: NavController) {

Spacer(modifier = Modifier.height(20.dp))

Text(
modifier = Modifier.padding(bottom = 10.dp),
text = stringResource(R.string.general),
style = TextStyle(fontSize = 16.sp, fontWeight = FontWeight.Medium)
)
SettingsSwitchCard(
text = stringResource(id = R.string.dark_mode),
icon = R.drawable.moon_icon,
isChecked = themeState.isDarkMode,
onCheckedChange = {
themeViewModel.toggleTheme()
}
)

SettingsComponent(
onClick = {
controller.navigate(NotifyScreens.TrashNoteScreen.name)
},
itemName = stringResource(id = R.string.trash),
iconId = R.drawable.ic_delete
)
SettingsItemGroup {
Text(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp),
text = stringResource(R.string.general),
style = TextStyle(fontSize = 16.sp, fontWeight = FontWeight.Medium)
)
SettingsSwitchCard(
text = stringResource(id = R.string.dark_mode),
icon = R.drawable.moon_icon,
isChecked = themeState.isDarkMode,
onCheckedChange = {
themeViewModel.toggleTheme()
}
)
SettingsComponent(
onClick = {
controller.navigate(NotifyScreens.TrashNoteScreen.name)
},
itemName = stringResource(id = R.string.trash),
iconId = R.drawable.ic_delete
)
}

Spacer(modifier = Modifier.height(20.dp))

Text(
modifier = Modifier.padding(bottom = 10.dp),
text = stringResource(R.string.security),
style = TextStyle(fontSize = 16.sp, fontWeight = FontWeight.Medium)
)
SettingsSwitchCard(
text = stringResource(id = R.string.block_ss),
icon = R.drawable.phonelink_lock,
isChecked = themeState.isSecureEnv,
onCheckedChange = {
themeViewModel.toggleSecureEnv()
}
)
SettingsItemGroup {
Text(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp),
text = stringResource(R.string.security),
style = TextStyle(fontSize = 16.sp, fontWeight = FontWeight.Medium)
)
SettingsSwitchCard(
text = stringResource(id = R.string.block_ss),
icon = R.drawable.phonelink_lock,
isChecked = themeState.isSecureEnv,
onCheckedChange = {
themeViewModel.toggleSecureEnv()
}
)

SettingsSwitchCard(
text = stringResource(id = R.string.biometric),
icon = R.drawable.ic_fingerprint,
isChecked = biometricAuthState,
onCheckedChange = {
settingsViewModel.showBiometricPrompt(context as MainActivity)
}
)
SettingsSwitchCard(
text = stringResource(id = R.string.biometric),
icon = R.drawable.ic_fingerprint,
isChecked = biometricAuthState,
onCheckedChange = {
settingsViewModel.showBiometricPrompt(context as MainActivity)
}
)
}

Spacer(modifier = Modifier.height(20.dp))

Text(
modifier = Modifier.padding(bottom = 10.dp),
text = stringResource(R.string.import_export),
fontSize = 16.sp,
fontFamily = FontFamily(Font(R.font.poppins_medium))
)
SettingsComponent(
onClick = {
exportLauncher.launch(Const.DATABASE_FILE_NAME)
},
itemName = stringResource(R.string.backup_data),
iconId = R.drawable.backup_icon
)
SettingsItemGroup {
Text(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp),
text = stringResource(R.string.import_export),
fontSize = 16.sp,
fontFamily = FontFamily(Font(R.font.poppins_medium))
)
SettingsComponent(
onClick = {
exportLauncher.launch(Const.DATABASE_FILE_NAME)
},
itemName = stringResource(R.string.backup_data),
iconId = R.drawable.backup_icon
)

SettingsComponent(
onClick = {
importLauncher.launch(arrayOf("*/*"))
},
itemName = stringResource(R.string.import_data),
iconId = R.drawable.import_icon
)
SettingsComponent(
onClick = {
importLauncher.launch(arrayOf("*/*"))
},
itemName = stringResource(R.string.import_data),
iconId = R.drawable.import_icon
)
}

Spacer(modifier = Modifier.height(20.dp))

Text(
modifier = Modifier.padding(bottom = 10.dp),
text = stringResource(R.string.others),
fontSize = 16.sp,
fontFamily = FontFamily(Font(R.font.poppins_medium))
)

SettingsComponent(
itemName = stringResource(R.string.rate_us_on_google_play),
iconId = R.drawable.star_icon
) {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse(Const.PLAY_STORE)
SettingsItemGroup {
Text(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp),
text = stringResource(R.string.others),
fontSize = 16.sp,
fontFamily = FontFamily(Font(R.font.poppins_medium))
)
context.startActivity(intent)
}

SettingsComponent(
itemName = stringResource(R.string.share_notify),
iconId = R.drawable.share_icon
) {
shareApp(context)
}
SettingsComponent(
itemName = stringResource(R.string.rate_us_on_google_play),
iconId = R.drawable.star_icon
) {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse(Const.PLAY_STORE)
)
context.startActivity(intent)
}

SettingsComponent(
itemName = stringResource(R.string.request_feature),
iconId = R.drawable.code
) {
val openURL = Intent(Intent.ACTION_VIEW)
openURL.data = Uri.parse(context.resources.getString(R.string.mailTo))
context.startActivity(openURL)
}
SettingsComponent(
itemName = stringResource(R.string.share_notify),
iconId = R.drawable.share_icon
) {
shareApp(context)
}

SettingsComponent(
itemName = stringResource(R.string.privacy_policy),
iconId = R.drawable.policy
) {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse(Const.PRIVACY_POLICY)
)
context.startActivity(intent)
SettingsComponent(
itemName = stringResource(R.string.request_feature),
iconId = R.drawable.code
) {
val openURL = Intent(Intent.ACTION_VIEW)
openURL.data = Uri.parse(context.resources.getString(R.string.mailTo))
context.startActivity(openURL)
}

SettingsComponent(
itemName = stringResource(R.string.privacy_policy),
iconId = R.drawable.policy
) {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse(Const.PRIVACY_POLICY)
)
context.startActivity(intent)
}
}
}

Expand All @@ -211,3 +235,17 @@ fun SettingsScreen(controller: NavController) {
)
}
}

@Composable
fun SettingsItemGroup(columnScope: @Composable ColumnScope.() -> Unit) {
Column(
modifier = Modifier
.widthIn(max = 500.dp)
.clip(RoundedCornerShape(12.dp))
.background(PrimaryContainerLight)
.padding(top = 13.dp, bottom = 7.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
columnScope()
}
}

0 comments on commit 1fad4a7

Please sign in to comment.