-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #246 from SuhasDissa/new-alarm-layout
feat: New Alarm Layout
- Loading branch information
Showing
16 changed files
with
889 additions
and
312 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
{ | ||
"formatVersion": 1, | ||
"database": { | ||
"version": 6, | ||
"identityHash": "7a3e746162031505f993deece80a8c46", | ||
"entities": [ | ||
{ | ||
"tableName": "timeZones", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `displayName` TEXT NOT NULL, `offset` INTEGER NOT NULL, PRIMARY KEY(`name`))", | ||
"fields": [ | ||
{ | ||
"fieldPath": "name", | ||
"columnName": "name", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "displayName", | ||
"columnName": "displayName", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "offset", | ||
"columnName": "offset", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"autoGenerate": false, | ||
"columnNames": [ | ||
"name" | ||
] | ||
}, | ||
"indices": [], | ||
"foreignKeys": [] | ||
}, | ||
{ | ||
"tableName": "alarms", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `time` INTEGER NOT NULL, `label` TEXT, `enabled` INTEGER NOT NULL, `days` TEXT NOT NULL, `vibrate` INTEGER NOT NULL, `soundName` TEXT, `soundUri` TEXT, `repeat` INTEGER NOT NULL DEFAULT 1, `snoozeEnabled` INTEGER NOT NULL DEFAULT 1, `snoozeMinutes` INTEGER NOT NULL DEFAULT 10, `soundEnabled` INTEGER NOT NULL DEFAULT 1)", | ||
"fields": [ | ||
{ | ||
"fieldPath": "id", | ||
"columnName": "id", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "time", | ||
"columnName": "time", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "label", | ||
"columnName": "label", | ||
"affinity": "TEXT", | ||
"notNull": false | ||
}, | ||
{ | ||
"fieldPath": "enabled", | ||
"columnName": "enabled", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "days", | ||
"columnName": "days", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "vibrate", | ||
"columnName": "vibrate", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "soundName", | ||
"columnName": "soundName", | ||
"affinity": "TEXT", | ||
"notNull": false | ||
}, | ||
{ | ||
"fieldPath": "soundUri", | ||
"columnName": "soundUri", | ||
"affinity": "TEXT", | ||
"notNull": false | ||
}, | ||
{ | ||
"fieldPath": "repeat", | ||
"columnName": "repeat", | ||
"affinity": "INTEGER", | ||
"notNull": true, | ||
"defaultValue": "1" | ||
}, | ||
{ | ||
"fieldPath": "snoozeEnabled", | ||
"columnName": "snoozeEnabled", | ||
"affinity": "INTEGER", | ||
"notNull": true, | ||
"defaultValue": "1" | ||
}, | ||
{ | ||
"fieldPath": "snoozeMinutes", | ||
"columnName": "snoozeMinutes", | ||
"affinity": "INTEGER", | ||
"notNull": true, | ||
"defaultValue": "10" | ||
}, | ||
{ | ||
"fieldPath": "soundEnabled", | ||
"columnName": "soundEnabled", | ||
"affinity": "INTEGER", | ||
"notNull": true, | ||
"defaultValue": "1" | ||
} | ||
], | ||
"primaryKey": { | ||
"autoGenerate": true, | ||
"columnNames": [ | ||
"id" | ||
] | ||
}, | ||
"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, '7a3e746162031505f993deece80a8c46')" | ||
] | ||
} | ||
} |
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
146 changes: 146 additions & 0 deletions
146
app/src/main/java/com/bnyro/clock/ui/common/SwitchWithDivider.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,146 @@ | ||
package com.bnyro.clock.ui.common | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.IntrinsicSize | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
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.Divider | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Surface | ||
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.contentDescription | ||
import androidx.compose.ui.semantics.semantics | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
fun SwitchWithDivider( | ||
title: String, | ||
description: String? = null, | ||
icon: ImageVector? = null, | ||
isChecked: Boolean = true, | ||
onClick: (() -> Unit) = {}, | ||
onChecked: (Boolean) -> Unit = {} | ||
) { | ||
Surface( | ||
modifier = Modifier.clickable( | ||
onClick = onClick | ||
) | ||
) { | ||
Row( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(8.dp, 16.dp) | ||
.height(IntrinsicSize.Min), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
icon?.let { | ||
Icon( | ||
imageVector = icon, | ||
contentDescription = null, | ||
modifier = Modifier | ||
.padding(start = 8.dp, end = 16.dp) | ||
.size(24.dp), | ||
tint = MaterialTheme.colorScheme.onSurfaceVariant | ||
) | ||
} | ||
Column( | ||
modifier = Modifier.weight(1f) | ||
) { | ||
Text(text = title, style = MaterialTheme.typography.titleLarge) | ||
if (!description.isNullOrEmpty()) { | ||
Text( | ||
text = description, | ||
style = MaterialTheme.typography.bodyMedium | ||
) | ||
} | ||
} | ||
Divider( | ||
modifier = Modifier | ||
.height(32.dp) | ||
.padding(horizontal = 8.dp) | ||
.width(1.dp) | ||
.align(Alignment.CenterVertically), | ||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.3f) | ||
) | ||
Switch( | ||
checked = isChecked, | ||
onCheckedChange = onChecked, | ||
modifier = Modifier | ||
.padding(horizontal = 6.dp) | ||
.semantics { | ||
contentDescription = title | ||
} | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun SwitchItem( | ||
title: String, | ||
description: String? = null, | ||
icon: ImageVector? = null, | ||
isChecked: Boolean = true, | ||
onClick: (Boolean) -> Unit | ||
) { | ||
Surface( | ||
modifier = Modifier.toggleable( | ||
value = isChecked, | ||
onValueChange = onClick | ||
) | ||
) { | ||
Row( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(8.dp, 16.dp) | ||
.padding(start = if (icon == null) 12.dp else 0.dp), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
icon?.let { | ||
Icon( | ||
imageVector = icon, | ||
contentDescription = null, | ||
modifier = Modifier | ||
.padding(start = 8.dp, end = 16.dp) | ||
.size(24.dp), | ||
tint = MaterialTheme.colorScheme.onSurfaceVariant | ||
) | ||
} | ||
Column( | ||
modifier = Modifier.weight(1f) | ||
) { | ||
Text(text = title, style = MaterialTheme.typography.titleLarge) | ||
if (!description.isNullOrEmpty()) { | ||
Text( | ||
text = description, | ||
style = MaterialTheme.typography.bodyMedium | ||
) | ||
} | ||
} | ||
Switch( | ||
checked = isChecked, | ||
onCheckedChange = null, | ||
modifier = Modifier.padding(start = 20.dp, end = 6.dp) | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun SwitchWithDividerPreview() { | ||
SwitchWithDivider(title = "My setting", description = "My description") | ||
} |
Oops, something went wrong.