Skip to content

Commit

Permalink
Merge pull request #98 from Spikeysanju/update-theme
Browse files Browse the repository at this point in the history
Refactoring & Theming Improvements
  • Loading branch information
Spikeysanju authored Nov 26, 2021
2 parents d232dce + d150bc3 commit f5fc246
Show file tree
Hide file tree
Showing 46 changed files with 1,677 additions and 612 deletions.
63 changes: 63 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ android {
applicationId = "dev.spikeysanju.einsen"
minSdk = 21
targetSdk = 30
versionCode = 3
versionName = "v1.0.0-alpha03"
versionCode = 4
versionName = "v1.0.0-alpha04"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -101,6 +101,13 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = rootProject.extra["composeVersion"] as String
}

packagingOptions {
// Multiple dependency bring these files in. Exclude them to enable
// our test APK to build (has no effect on our AARs)
resources.excludes += "/META-INF/AL2.0"
resources.excludes += "/META-INF/LGPL2.1"
}
}
dependencies {

Expand All @@ -124,7 +131,6 @@ dependencies {
implementation("com.google.firebase:firebase-crashlytics-ktx")
implementation("com.google.firebase:firebase-analytics-ktx")


// compose navigation
implementation("androidx.navigation:navigation-compose:${rootProject.extra["composeNavigationVersion"]}")
implementation("androidx.hilt:hilt-navigation-compose:${rootProject.extra["hiltComposeNavVersion"]}")
Expand Down
100 changes: 100 additions & 0 deletions app/schemas/dev.spikeysanju.einsen.data.local.db.EinsenDatabase/3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"formatVersion": 1,
"database": {
"version": 3,
"identityHash": "fae9ad0864a134de9ae29b1f5c5bbd7c",
"entities": [
{
"tableName": "task",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`title` TEXT NOT NULL, `description` TEXT NOT NULL, `category` TEXT NOT NULL, `Emoji` TEXT NOT NULL, `urgency` INTEGER NOT NULL, `importance` INTEGER NOT NULL, `priority` TEXT NOT NULL, `timer` TEXT NOT NULL, `isCompleted` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
"fields": [
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "description",
"columnName": "description",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "category",
"columnName": "category",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "emoji",
"columnName": "Emoji",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "urgency",
"columnName": "urgency",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "importance",
"columnName": "importance",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "priority",
"columnName": "priority",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "due",
"columnName": "timer",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "isCompleted",
"columnName": "isCompleted",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "createdAt",
"columnName": "createdAt",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "updatedAt",
"columnName": "updatedAt",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'fae9ad0864a134de9ae29b1f5c5bbd7c')"
]
}
}
17 changes: 10 additions & 7 deletions app/src/main/java/dev/spikeysanju/einsen/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ import com.google.accompanist.systemuicontroller.rememberSystemUiController
import dagger.hilt.android.AndroidEntryPoint
import dev.spikeysanju.einsen.data.local.datastore.ThemeManager
import dev.spikeysanju.einsen.navigation.NavGraph
import dev.spikeysanju.einsen.ui.theme.EinsenTheme
import dev.spikeysanju.einsen.ui.theme.einsenColors
import dev.spikeysanju.einsen.ui.theme.apptheme.AppTheme.AppTheme
import dev.spikeysanju.einsen.ui.theme.color.darkColors
import dev.spikeysanju.einsen.ui.theme.color.lightColors
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
import javax.inject.Inject
Expand Down Expand Up @@ -67,16 +68,18 @@ class MainActivity : AppCompatActivity() {
val darkMode by themeManager.uiModeFlow.collectAsState(initial = isSystemInDarkTheme())

/**
* Set UI Mode accordingly
* Change UI Mode on toggle
*/
val toggleTheme: () -> Unit = {
lifecycleScope.launch {
themeManager.setDarkMode(!darkMode)
}
}

EinsenTheme(darkTheme = darkMode) {
Surface(color = einsenColors.bg) {
val colors = if (darkMode) darkColors() else lightColors()

AppTheme(colors = colors) {
Surface(color = dev.spikeysanju.einsen.ui.theme.apptheme.AppTheme.colors.background) {
SetStatusBarColor()
NavGraph(toggleTheme)
}
Expand All @@ -100,7 +103,7 @@ class MainActivity : AppCompatActivity() {
fun SetStatusBarColor() {
// Remember a SystemUiController
val systemUiController = rememberSystemUiController()
val color = einsenColors.bg
val color = dev.spikeysanju.einsen.ui.theme.apptheme.AppTheme.colors.background

/**
* Update all of the system bar colors to be transparent, and use
Expand All @@ -114,6 +117,6 @@ fun SetStatusBarColor() {
@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
EinsenTheme {
AppTheme {
}
}
56 changes: 48 additions & 8 deletions app/src/main/java/dev/spikeysanju/einsen/components/BottomCTA.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package dev.spikeysanju.einsen.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
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
Expand All @@ -38,9 +39,10 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import dev.spikeysanju.einsen.R
import dev.spikeysanju.einsen.ui.theme.einsenColors
import dev.spikeysanju.einsen.ui.theme.apptheme.AppTheme

/**
* This component helps to perform action for each task like Edit, Delete & Share task of this app.
Expand All @@ -63,19 +65,26 @@ fun BottomCTA(
onShare: () -> Unit,
onButtonChange: () -> Unit
) {

Box(
modifier = modifier
.fillMaxWidth()
.height(80.dp)
.background(einsenColors.card),
.background(AppTheme.colors.card),
contentAlignment = Alignment.Center
) {
Row(
modifier = modifier.padding(top = 12.dp, bottom = 12.dp, start = 16.dp, end = 16.dp),
horizontalArrangement = Arrangement.SpaceAround
modifier = modifier.padding(
top = AppTheme.dimensions.paddingLarge,
bottom = AppTheme.dimensions.paddingLarge,
start = AppTheme.dimensions.paddingXL,
end = AppTheme.dimensions.paddingXL
),
horizontalArrangement = Arrangement.SpaceAround,
verticalAlignment = Alignment.CenterVertically
) {
ActionIcons(onEdit = { onEdit() }, onDelete = { onDelete() }, onShare = { onShare() })
Spacer(modifier = modifier.width(12.dp))
Spacer(modifier = modifier.width(AppTheme.dimensions.paddingLarge))

Row(modifier = modifier.fillMaxWidth(), Arrangement.End) {
PrimaryButtonWithIcon(
Expand Down Expand Up @@ -109,24 +118,55 @@ fun ActionIcons(
Icon(
painter = painterResource(id = R.drawable.ic_edit),
contentDescription = stringResource(R.string.text_edit_button),
tint = einsenColors.icon
tint = AppTheme.colors.primary
)
}

IconButton(onClick = { onDelete.invoke() }) {
Icon(
painter = painterResource(id = R.drawable.ic_delete),
contentDescription = stringResource(R.string.text_delete_button),
tint = einsenColors.icon
tint = AppTheme.colors.primary
)
}

IconButton(onClick = { onShare.invoke() }) {
Icon(
painter = painterResource(id = R.drawable.ic_share),
contentDescription = stringResource(R.string.text_share_button),
tint = einsenColors.icon
tint = AppTheme.colors.primary
)
}
}
}

@Preview(name = "Bottom CTA", group = "Button")
@Composable
fun BottomCTA() {

Column {

BottomCTA(
title = "Complete",
icon = painterResource(id = R.drawable.ic_check),
color = AppTheme.colors.black,
onEdit = { },
onDelete = { },
onShare = { }
) {
}

Spacer(modifier = Modifier.height(AppTheme.dimensions.paddingMedium))

ActionIcons(
onEdit = {
// on edit action goes here
},
onDelete = {
// on delete action goes here
}
) {
// on share action goes here
}
}
}
Loading

0 comments on commit f5fc246

Please sign in to comment.