Skip to content

Commit 42ea555

Browse files
authored
Fixed the inconsistencies in the Deepr App (#173)
1 parent 3458e45 commit 42ea555

File tree

7 files changed

+29
-12
lines changed

7 files changed

+29
-12
lines changed

app/src/main/java/com/yogeshpaliyal/deepr/ui/components/ServerStatusBar.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import androidx.compose.foundation.layout.padding
99
import androidx.compose.foundation.layout.size
1010
import androidx.compose.material3.CardDefaults
1111
import androidx.compose.material3.Icon
12+
import androidx.compose.material3.MaterialTheme
1213
import androidx.compose.material3.OutlinedCard
1314
import androidx.compose.material3.Text
1415
import androidx.compose.runtime.Composable
1516
import androidx.compose.runtime.getValue
1617
import androidx.compose.ui.Alignment
1718
import androidx.compose.ui.Modifier
18-
import androidx.compose.ui.graphics.Color
1919
import androidx.compose.ui.res.stringResource
2020
import androidx.compose.ui.text.font.FontWeight
2121
import androidx.compose.ui.unit.dp
@@ -39,8 +39,8 @@ fun ServerStatusBar(
3939
if (isRunning) {
4040
OutlinedCard(
4141
modifier = modifier.padding(8.dp),
42-
colors = CardDefaults.outlinedCardColors(containerColor = Color(0xFF4CAF50)),
43-
border = BorderStroke(1.dp, Color(0xFF3C8D3E)),
42+
colors = CardDefaults.outlinedCardColors(containerColor = MaterialTheme.colorScheme.primary),
43+
border = BorderStroke(1.dp, MaterialTheme.colorScheme.primary),
4444
) {
4545
Row(
4646
modifier =
@@ -54,20 +54,20 @@ fun ServerStatusBar(
5454
Icon(
5555
TablerIcons.Server,
5656
contentDescription = null,
57-
tint = Color.White,
57+
tint = MaterialTheme.colorScheme.onPrimary,
5858
modifier = Modifier.size(16.dp),
5959
)
6060
Text(
6161
text = stringResource(R.string.server_running_tap_to_configure),
62-
color = Color.White,
62+
color = MaterialTheme.colorScheme.onPrimary,
6363
fontSize = 14.sp,
6464
fontWeight = FontWeight.Medium,
6565
modifier = Modifier.weight(1f),
6666
)
6767
if (serverUrl != null) {
6868
Text(
6969
text = serverUrl!!.substringAfter("://"),
70-
color = Color.White.copy(alpha = 0.8f),
70+
color = MaterialTheme.colorScheme.onPrimary.copy(alpha = 0.8f),
7171
fontSize = 12.sp,
7272
)
7373
}

app/src/main/java/com/yogeshpaliyal/deepr/ui/screens/AboutUs.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ fun AboutUsScreen(
109109
)
110110
Spacer(modifier = Modifier.height(32.dp))
111111
Card(modifier = Modifier.fillMaxWidth()) {
112-
Column(modifier = Modifier.padding(16.dp)) {
112+
Column(modifier = Modifier.padding(16.dp).fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
113113
Text(
114114
text = stringResource(R.string.author),
115115
style = MaterialTheme.typography.titleLarge,

app/src/main/java/com/yogeshpaliyal/deepr/ui/screens/LocalNetworkServer.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import androidx.compose.runtime.snapshots.SnapshotStateList
3636
import androidx.compose.ui.Alignment
3737
import androidx.compose.ui.Modifier
3838
import androidx.compose.ui.draw.scale
39-
import androidx.compose.ui.graphics.Color
4039
import androidx.compose.ui.platform.LocalContext
4140
import androidx.compose.ui.platform.LocalLayoutDirection
4241
import androidx.compose.ui.res.stringResource
@@ -146,7 +145,7 @@ fun LocalNetworkServerScreen(
146145
contentDescription = null,
147146
tint =
148147
if (isRunning) {
149-
Color(0xFF4CAF50)
148+
MaterialTheme.colorScheme.primary
150149
} else {
151150
MaterialTheme.colorScheme.onSurface
152151
},

app/src/main/java/com/yogeshpaliyal/deepr/ui/screens/home/DeeprItem.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ fun DeeprItem(
172172
} else {
173173
stringResource(R.string.add_to_favourites)
174174
},
175+
tint =
176+
if (account.isFavourite == 1L) {
177+
MaterialTheme.colorScheme.primary
178+
} else {
179+
MaterialTheme.colorScheme.onSurface
180+
},
175181
)
176182
}
177183

app/src/main/java/com/yogeshpaliyal/deepr/ui/screens/home/Home.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ fun HomeScreen(
127127
val textFieldState = rememberTextFieldState()
128128
val scope = rememberCoroutineScope()
129129
val totalLinks = viewModel.countOfLinks.collectAsStateWithLifecycle()
130+
val favouriteLinks = viewModel.countOfFavouriteLinks.collectAsStateWithLifecycle()
130131

131132
val qrScanner =
132133
rememberLauncherForActivityResult(
@@ -174,7 +175,7 @@ fun HomeScreen(
174175
if (searchBarState.currentValue == SearchBarValue.Collapsed) {
175176
Text(
176177
modifier = Modifier.fillMaxWidth(),
177-
text = stringResource(R.string.search) + " (" + totalLinks.value + ")",
178+
text = stringResource(R.string.search),
178179
textAlign = TextAlign.Center,
179180
)
180181
}
@@ -269,7 +270,7 @@ fun HomeScreen(
269270
),
270271
onClick = { viewModel.setFavouriteFilter(-1) },
271272
selected = favouriteFilter == -1,
272-
label = { Text(stringResource(R.string.all)) },
273+
label = { Text(stringResource(R.string.all) + " (${totalLinks.value ?: 0})") },
273274
)
274275
SegmentedButton(
275276
shape =
@@ -279,7 +280,7 @@ fun HomeScreen(
279280
),
280281
onClick = { viewModel.setFavouriteFilter(1) },
281282
selected = favouriteFilter == 1,
282-
label = { Text(stringResource(R.string.favourites)) },
283+
label = { Text(stringResource(R.string.favourites) + " (${favouriteLinks.value ?: 0})") },
283284
)
284285
}
285286
}

app/src/main/java/com/yogeshpaliyal/deepr/viewmodel/AccountViewModel.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ class AccountViewModel(
100100
viewModelScope.coroutineContext,
101101
).stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0L)
102102

103+
val countOfFavouriteLinks: StateFlow<Long?> =
104+
deeprQueries
105+
.countOfFavouriteLinks()
106+
.asFlow()
107+
.mapToOneOrNull(
108+
viewModelScope.coroutineContext,
109+
).stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0L)
110+
103111
private val sortOrder: Flow<@SortType String> =
104112
preferenceDataStore.getSortingOrder
105113

app/src/main/sqldelight/com/yogeshpaliyal/deepr/Deepr.sq

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ ORDER BY Tags.name;
162162
countOfLinks:
163163
SELECT count(*) FROM Deepr;
164164

165+
countOfFavouriteLinks:
166+
SELECT count(*) FROM Deepr WHERE isFavourite = 1;
167+
165168

166169
-- Link-Tag relations
167170
addTagToLink:

0 commit comments

Comments
 (0)