Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #40 from thatsmanmeet/dev
Browse files Browse the repository at this point in the history
Merge dev in master
  • Loading branch information
thatsmanmeet authored Jul 8, 2023
2 parents 8bf1d34 + 72eb13b commit c892deb
Show file tree
Hide file tree
Showing 16 changed files with 251 additions and 42 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.thatsmanmeet.taskyapp"
minSdk 26
targetSdk 34
versionCode 19
versionName "2.3.5"
versionCode 20
versionName "2.3.6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
Expand Down Expand Up @@ -77,7 +77,7 @@ dependencies {
annotationProcessor "androidx.room:room-compiler:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation 'androidx.core:core-splashscreen:1.0.1'
implementation "androidx.navigation:navigation-compose:2.7.0-beta01"
implementation "androidx.navigation:navigation-compose:2.7.0-beta02"
implementation "androidx.datastore:datastore-preferences:1.0.0"
def lottieVersion = "6.0.0"
implementation "com.airbnb.android:lottie-compose:$lottieVersion"
Expand Down
2 changes: 1 addition & 1 deletion app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 18,
"versionCode": 19,
"versionName": "2.3.5",
"outputFile": "app-release.apk"
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
android:name=".MainActivity"
android:exported="true"
android:theme="@style/Theme.App.Starting"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden">
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|uiMode">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.thatsmanmeet.taskyapp.components

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.DateRange
Expand All @@ -21,8 +20,7 @@ fun DateHeader(
Row(
modifier = modifier
.padding(bottom = 10.dp, top = 0.dp)
.fillMaxWidth()
.background(MaterialTheme.colorScheme.surface),
.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
) {
Icon(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.thatsmanmeet.taskyapp.R
import com.thatsmanmeet.taskyapp.constants.Constants
import com.thatsmanmeet.taskyapp.datastore.SettingsStore
import com.thatsmanmeet.taskyapp.room.Todo
import com.thatsmanmeet.taskyapp.room.TodoViewModel
import com.thatsmanmeet.taskyapp.screens.cancelNotification
Expand Down Expand Up @@ -81,6 +81,8 @@ fun OpenEditTodoDialog(
set(Calendar.MINUTE, 0)
set(Calendar.SECOND, 0)
}
val settingsStore = SettingsStore(context = context)
val savedSoundKey = settingsStore.getSoundKey.collectAsState(initial = true)
var todo : Todo
AlertDialog(
onDismissRequest = {
Expand Down Expand Up @@ -272,7 +274,9 @@ fun OpenEditTodoDialog(
todo = todo
)
enteredText1 = ""
todoViewModel.playDeletedSound(context)
if(savedSoundKey.value == true){
todoViewModel.playDeletedSound(context)
}
},
colors = ButtonDefaults.buttonColors(
containerColor = Color(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fun TaskCompleteAnimations(
progressAnimation
},
modifier = modifier.fillMaxSize(),
contentScale = ContentScale.Fit
contentScale = ContentScale.Crop
)

}
125 changes: 125 additions & 0 deletions app/src/main/java/com/thatsmanmeet/taskyapp/components/ThemeDialog.kt
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)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.preferencesDataStore
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
Expand All @@ -18,6 +19,7 @@ class SettingsStore(
val ANIMATION_SHOW_KEY = booleanPreferencesKey("animation_list_preference")
val SHOW_24_HOUR_CLOCK_KEY = booleanPreferencesKey("show_24_hour_clock_preference")
val TASK_COMPLETION_SOUNDS = booleanPreferencesKey("sound_list_preference")
val THEME_MODE_KEY = stringPreferencesKey("theme_mode_preference")
}

val getTaskListKey : Flow<Boolean?> = context.dataStore.data.map {preference->
Expand All @@ -35,6 +37,10 @@ class SettingsStore(
preference[TASK_COMPLETION_SOUNDS] ?: true
}

val getThemeModeKey : Flow<String?> = context.dataStore.data.map {preference ->
preference[THEME_MODE_KEY] ?: ""
}

suspend fun saveTaskListKey(isEnabled:Boolean) {
context.dataStore.edit {preferences->
preferences[TASK_LIST_KEY] = isEnabled
Expand All @@ -57,4 +63,10 @@ class SettingsStore(
preference[SHOW_24_HOUR_CLOCK_KEY] = isEnabled
}
}

suspend fun saveThemeModeKey(mode:String){
context.dataStore.edit { preference->
preference[THEME_MODE_KEY] = mode
}
}
}
8 changes: 8 additions & 0 deletions app/src/main/java/com/thatsmanmeet/taskyapp/misc/AppTheme.kt
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
)
58 changes: 34 additions & 24 deletions app/src/main/java/com/thatsmanmeet/taskyapp/screens/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.content.Context
import android.content.Intent
import android.media.AudioAttributes
import android.net.Uri
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.*
import androidx.compose.material.icons.Icons
Expand Down Expand Up @@ -92,7 +93,15 @@ fun MyApp(
val settingsStore = SettingsStore(context)
val savedTaskKey = settingsStore.getTaskListKey.collectAsState(initial = true)
val savedAnimationKey = settingsStore.getAnimationKey.collectAsState(initial = true)
TaskyTheme {
val savedThemeKey = settingsStore.getThemeModeKey.collectAsState(initial = "")
TaskyTheme(darkTheme = when (savedThemeKey.value) {
"0" -> {
isSystemInDarkTheme()
}
"1" -> {false}
else -> {true}
}
) {
Scaffold(
topBar = {
TopAppBar(
Expand Down Expand Up @@ -152,7 +161,9 @@ fun MyApp(
color = MaterialTheme.colorScheme.background
) {
if(todoListFromFlow.isEmpty()){
Box(modifier = modifier.fillMaxSize(),
Box(modifier = modifier
.fillMaxSize()
.padding(paddingValues),
contentAlignment = Alignment.Center) {
Column(
modifier = modifier,
Expand All @@ -176,28 +187,27 @@ fun MyApp(
}
}
}else {
if(savedTaskKey.value == null || savedTaskKey.value == true){
TaskList(
state = listState,
list = todoListFromFlow,
todoViewModel = todoViewModel,
onClick = {index->
selectedItem.value = index
openEditDialog.value = true
}
)
}else{
LegacyTaskList(
state = listState,
list = todoListFromFlow,
todoViewModel = todoViewModel,
onClick = {index->
selectedItem.value = index
openEditDialog.value = true
}
)
}

if(savedTaskKey.value == null || savedTaskKey.value == true){
TaskList(
state = listState,
list = todoListFromFlow,
todoViewModel = todoViewModel,
onClick = {index->
selectedItem.value = index
openEditDialog.value = true
}
)
}else{
LegacyTaskList(
state = listState,
list = todoListFromFlow,
todoViewModel = todoViewModel,
onClick = {index->
selectedItem.value = index
openEditDialog.value = true
}
)
}
}
if (openEditDialog.value){
OpenEditTodoDialog(
Expand Down
Loading

0 comments on commit c892deb

Please sign in to comment.