This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4456c3
commit 72eb13b
Showing
14 changed files
with
239 additions
and
34 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
125 changes: 125 additions & 0 deletions
125
app/src/main/java/com/thatsmanmeet/taskyapp/components/ThemeDialog.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,125 @@ | ||
package com.thatsmanmeet.taskyapp.components | ||
|
||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Arrangement | ||
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.width | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.items | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Check | ||
import androidx.compose.material3.AlertDialog | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.ButtonColors | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.MutableState | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import com.thatsmanmeet.taskyapp.R | ||
import com.thatsmanmeet.taskyapp.misc.AppTheme | ||
|
||
|
||
@Composable | ||
fun ThemeChangerDialog( | ||
modifier: Modifier = Modifier, | ||
selectedItem:MutableState<String>, | ||
isShowing:MutableState<Boolean>, | ||
onClick : (String) -> Unit | ||
) { | ||
if(isShowing.value){ | ||
AlertDialog( | ||
onDismissRequest = { | ||
isShowing.value = false | ||
}, | ||
title = { | ||
Text(text = stringResource(R.string.select_app_theme_text)) | ||
}, | ||
text = { | ||
Column( | ||
horizontalAlignment = Alignment.Start, | ||
verticalArrangement = Arrangement.Center | ||
) { | ||
val list = mutableListOf( | ||
AppTheme("0","System Default",false, R.drawable.ic_phone), | ||
AppTheme("1","Light",false,R.drawable.ic_light), | ||
AppTheme("2","Dark",false,R.drawable.ic_dark) | ||
) | ||
LazyColumn(modifier = modifier.padding(2.dp)){ | ||
items(list){theme-> | ||
ThemeItem(appTheme = theme, selectedThemeId = selectedItem) { selectedThemeId -> | ||
selectedItem.value = selectedThemeId | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
confirmButton = { | ||
Button( | ||
onClick = { | ||
onClick(selectedItem.value) | ||
isShowing.value = false | ||
}, | ||
colors = ButtonColors(containerColor = Color(0xFF229E28), contentColor = Color.White, disabledContentColor = Color.White, disabledContainerColor = Color.Gray) | ||
) { | ||
Text(text = "OK") | ||
} | ||
}, | ||
dismissButton = { | ||
Button( | ||
onClick = { | ||
isShowing.value = false | ||
}, | ||
colors = ButtonColors(containerColor = Color(0xFFDB4C41), contentColor = Color.White, disabledContentColor = Color.White, disabledContainerColor = Color.Gray) | ||
) { | ||
Text(text = "Cancel") | ||
} | ||
} | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
fun ThemeItem( | ||
modifier: Modifier = Modifier, | ||
appTheme: AppTheme, | ||
selectedThemeId: MutableState<String>, | ||
onThemeItemSelected: (String) -> Unit | ||
) { | ||
val isSelected = remember(appTheme.id == selectedThemeId.value) { | ||
mutableStateOf(appTheme.id == selectedThemeId.value) | ||
} | ||
|
||
Row( | ||
modifier = modifier.padding(10.dp).fillMaxWidth().clickable { | ||
onThemeItemSelected(appTheme.id) | ||
}, | ||
horizontalArrangement = Arrangement.SpaceBetween, | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
Row(verticalAlignment = Alignment.CenterVertically) { | ||
Icon(painter = painterResource(id = appTheme.icon), contentDescription = null) | ||
Spacer(modifier = modifier.width(10.dp)) | ||
Text(text = appTheme.mode) | ||
} | ||
if (isSelected.value) { | ||
Icon( | ||
imageVector = Icons.Default.Check, | ||
contentDescription = null, | ||
tint = Color(0xFF009688) | ||
) | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.thatsmanmeet.taskyapp.misc | ||
|
||
data class AppTheme( | ||
val id:String, | ||
val mode:String, | ||
var isSelected:Boolean, | ||
val icon:Int | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#000000" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M12,3c-4.97,0 -9,4.03 -9,9s4.03,9 9,9s9,-4.03 9,-9c0,-0.46 -0.04,-0.92 -0.1,-1.36c-0.98,1.37 -2.58,2.26 -4.4,2.26c-2.98,0 -5.4,-2.42 -5.4,-5.4c0,-1.81 0.89,-3.42 2.26,-4.4C12.92,3.04 12.46,3 12,3L12,3z"/> | ||
</vector> |
Oops, something went wrong.