Settings added
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package `in`.sminnovations.attendanceapp.screens.settings
|
||||
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.wrapContentSize
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.OutlinedCard
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.dp
|
||||
import `in`.sminnovations.attendanceapp.screens.settings.data.SettingsData
|
||||
import `in`.sminnovations.attendanceapp.screens.settings.components.TopComponents
|
||||
import `in`.sminnovations.attendanceapp.screens.settings.components.subSetting.AboutSettings
|
||||
import `in`.sminnovations.attendanceapp.screens.settings.components.subSetting.Appearance
|
||||
|
||||
@Composable
|
||||
fun SettingsScreen() {
|
||||
val context = LocalContext.current
|
||||
val dataStore = SettingsData(context)
|
||||
val scrollState = rememberScrollState()
|
||||
val devMode = dataStore.getDevModeToggle.collectAsState(initial = false)
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.verticalScroll(scrollState)
|
||||
.fillMaxSize(),
|
||||
) {
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
TopComponents()
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
OutlinedCard(
|
||||
modifier = Modifier
|
||||
.padding(10.dp)
|
||||
.wrapContentSize()
|
||||
) {
|
||||
|
||||
Appearance(context = context)
|
||||
AboutSettings(context = context)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package `in`.sminnovations.attendanceapp.screens.home.navigationDrawer.ui.components
|
||||
package `in`.sminnovations.attendanceapp.screens.settings.components
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
@@ -28,25 +28,12 @@ import `in`.sminnovations.attendanceapp.R
|
||||
|
||||
@Composable
|
||||
fun TopComponents(
|
||||
onclose : () -> Unit
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.Absolute.Right
|
||||
) {
|
||||
IconButton(
|
||||
onClick = {onclose()},
|
||||
modifier = Modifier.padding(10.dp)
|
||||
) {
|
||||
Icon(painter = painterResource(id =R.drawable.baseline_close_24 ), contentDescription ="close" )
|
||||
}
|
||||
|
||||
}
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.smi_logo), // replace with your image resource
|
||||
contentDescription = "Profile Photo",
|
||||
@@ -59,7 +46,7 @@ fun TopComponents(
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
Text(
|
||||
text = "John Doe",
|
||||
text = "Sathwik C S",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 20.sp,
|
||||
@@ -69,7 +56,7 @@ fun TopComponents(
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Text(
|
||||
text = "ID: 123456",
|
||||
text = "ID: 69420",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
fontSize = 16.sp
|
||||
@@ -78,7 +65,7 @@ fun TopComponents(
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
|
||||
Text(
|
||||
text = "Software Engineer",
|
||||
text = "Android Developer",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
fontSize = 16.sp
|
||||
@@ -0,0 +1,126 @@
|
||||
package `in`.sminnovations.attendanceapp.screens.settings.components.settingsComponents
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
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.wrapContentSize
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedCard
|
||||
import androidx.compose.material3.RadioButton
|
||||
import androidx.compose.material3.Text
|
||||
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 androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import `in`.sminnovations.attendanceapp.R
|
||||
|
||||
|
||||
@Composable
|
||||
fun RadioDialogue(
|
||||
showDialog:Boolean,
|
||||
listOptions:List<String>,
|
||||
headText:String,
|
||||
selectedOption:String,
|
||||
onClose: () -> Unit,
|
||||
gotOption:(String)->Unit
|
||||
) {
|
||||
|
||||
if (showDialog) {
|
||||
Dialog(
|
||||
onDismissRequest = { onClose() },
|
||||
DialogProperties(
|
||||
dismissOnBackPress = true,
|
||||
dismissOnClickOutside = true,
|
||||
usePlatformDefaultWidth = true
|
||||
)
|
||||
) {
|
||||
OutlinedCard(
|
||||
modifier = Modifier
|
||||
.wrapContentSize()
|
||||
.clickable { onClose() },
|
||||
) {
|
||||
BackHandler(onBack = onClose)
|
||||
Box(
|
||||
// modifier = Modifier
|
||||
// .background(MaterialTheme.colorScheme.su)
|
||||
) {
|
||||
Column {
|
||||
Text(
|
||||
text = headText,
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterHorizontally)
|
||||
.padding(20.dp)
|
||||
)
|
||||
|
||||
LazyColumn(
|
||||
modifier =
|
||||
if (listOptions.size <=5) {
|
||||
Modifier
|
||||
.padding(20.dp, 20.dp, 20.dp, 0.dp)
|
||||
.wrapContentSize()
|
||||
}else {
|
||||
Modifier
|
||||
.padding(20.dp, 20.dp, 20.dp, 0.dp)
|
||||
.height(400.dp)
|
||||
},
|
||||
)
|
||||
{
|
||||
items(listOptions) { option ->
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable {
|
||||
gotOption(option)
|
||||
onClose()
|
||||
},
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
RadioButtonComponent(value = selectedOption, onValueChange = {
|
||||
gotOption(option)
|
||||
onClose()
|
||||
}, placeholder = option)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
}
|
||||
}
|
||||
Row {
|
||||
Spacer(Modifier.weight(1f))
|
||||
Text(
|
||||
text = stringResource(R.string.cancel),
|
||||
modifier = Modifier
|
||||
.padding(0.dp, 0.dp, 40.dp, 20.dp)
|
||||
.clickable { onClose() },
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun RadioButtonComponent(value: String, onValueChange: (String) -> Unit, placeholder: String) {
|
||||
RadioButton(
|
||||
selected = value == placeholder,
|
||||
onClick = { onValueChange(placeholder) }
|
||||
)
|
||||
Text(
|
||||
text = placeholder,
|
||||
modifier = Modifier.padding(start = 8.dp)
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package `in`.sminnovations.attendanceapp.screens.settings.components.settingsComponents
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import `in`.sminnovations.attendanceapp.screens.settings.components.settingsComponents.ClickableCard
|
||||
import `in`.sminnovations.attendanceapp.screens.settings.components.settingsComponents.RadioDialogue
|
||||
|
||||
|
||||
@Composable
|
||||
fun RadioCard(
|
||||
title:String,
|
||||
subtitle:String,
|
||||
icon: ImageVector,
|
||||
radioHeader:String,
|
||||
gotOption:(String)->Unit,
|
||||
listOptions:List<String>,
|
||||
selectedOption:String
|
||||
) {
|
||||
var showDialog by remember { mutableStateOf(false) }
|
||||
ClickableCard(
|
||||
title = title,
|
||||
subtitle = subtitle,
|
||||
onClick = {
|
||||
showDialog = true
|
||||
},
|
||||
icon = icon
|
||||
)
|
||||
RadioDialogue(
|
||||
showDialog = showDialog,
|
||||
listOptions =listOptions,
|
||||
headText =radioHeader ,
|
||||
selectedOption = selectedOption,
|
||||
onClose = { showDialog=false},
|
||||
gotOption = gotOption
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package `in`.sminnovations.attendanceapp.screens.settings.components.settingsComponents
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
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.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.selection.toggleable
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
|
||||
@Composable
|
||||
fun SwitchCard(
|
||||
checkedValue:Boolean,
|
||||
title:String,
|
||||
subtitle:String,
|
||||
onSwitchChange: (Boolean) -> Unit,
|
||||
icon: ImageVector
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
// .background(MaterialTheme.colorScheme.surfaceContainer)
|
||||
.toggleable(
|
||||
value = checkedValue,
|
||||
enabled = true,
|
||||
role = Role.Switch,
|
||||
onValueChange = onSwitchChange
|
||||
)
|
||||
.padding(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(
|
||||
imageVector = icon,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(24.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
Column(
|
||||
modifier = Modifier.weight(1f)
|
||||
) {
|
||||
Text(
|
||||
text = title,
|
||||
fontWeight = FontWeight.Bold,
|
||||
style = MaterialTheme.typography.bodyLarge
|
||||
)
|
||||
Text(
|
||||
text = subtitle,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
}
|
||||
Switch(
|
||||
checked = checkedValue,
|
||||
onCheckedChange = onSwitchChange
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user