Skip to content

Commit fcc7b2a

Browse files
committed
fix typo
1 parent d8e4a80 commit fcc7b2a

File tree

42 files changed

+124
-183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+124
-183
lines changed

Diff for: app/src/main/kotlin/br/com/mob1st/bet/init/KoinInitializer.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class KoinInitializer : Initializer<KoinApplication> {
3333
private fun Context.createDependencyGraph() =
3434
startKoin {
3535
androidLogger()
36-
androidContext(this@createDependencyGraph)
36+
androidContext(this@createDependencyGraph.applicationContext)
3737
modules(
3838
FirebaseComponent().module,
3939
firebaseModule,
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,24 @@
11
package br.com.mob1st.core.androidx.flows
22

3-
import android.os.Handler
4-
import android.os.Looper
5-
import android.view.Choreographer
6-
import android.view.Choreographer.FrameCallback
73
import kotlinx.coroutines.CoroutineScope
8-
import kotlinx.coroutines.ExperimentalCoroutinesApi
94
import kotlinx.coroutines.flow.Flow
10-
import kotlinx.coroutines.flow.SharingCommand
115
import kotlinx.coroutines.flow.SharingStarted
126
import kotlinx.coroutines.flow.StateFlow
13-
import kotlinx.coroutines.flow.distinctUntilChanged
14-
import kotlinx.coroutines.flow.dropWhile
15-
import kotlinx.coroutines.flow.map
16-
import kotlinx.coroutines.flow.mapLatest
177
import kotlinx.coroutines.flow.stateIn
18-
import kotlinx.coroutines.suspendCancellableCoroutine
19-
import kotlin.coroutines.resume
208

21-
/**
22-
* Behaves like [SharingStarted.WhileSubscribed] but it will also wait for config changes to settle and for the UI to
23-
* have a chance to resubscribe before stopping the upstream flow
24-
* @see <a href="https://blog.p-y.wtf/whilesubscribed5000">WhileSubscribed(5000)</a>
25-
*/
26-
object WhileSubscribedOrRetained : SharingStarted {
27-
private val handler = Handler(Looper.getMainLooper())
28-
29-
@OptIn(ExperimentalCoroutinesApi::class)
30-
override fun command(subscriptionCount: StateFlow<Int>): Flow<SharingCommand> =
31-
subscriptionCount
32-
.map { it > 0 }
33-
.distinctUntilChanged()
34-
.mapLatest { hasSubscribers ->
35-
if (hasSubscribers) {
36-
SharingCommand.START
37-
} else {
38-
awaitChoreographerFramePostFrontOfQueue()
39-
SharingCommand.STOP
40-
}
41-
}
42-
.dropWhile { it != SharingCommand.START }
43-
.distinctUntilChanged()
44-
45-
private suspend fun awaitChoreographerFramePostFrontOfQueue() = suspendCancellableCoroutine { continuation ->
46-
val frameCallback = postPostPost {
47-
if (!continuation.isCompleted) {
48-
continuation.resume(Unit)
49-
}
50-
}
51-
continuation.invokeOnCancellation {
52-
Choreographer.getInstance().removeFrameCallback(frameCallback)
53-
}
54-
}
55-
56-
private fun postPostPost(postBlock: () -> Unit): FrameCallback {
57-
// This code is perfect. Do not change a thing.
58-
val frameCallback = FrameCallback {
59-
handler.postAtFrontOfQueue {
60-
handler.post {
61-
postBlock()
62-
}
63-
}
64-
}
65-
return frameCallback.apply {
66-
Choreographer.getInstance().postFrameCallback(this)
67-
}
68-
}
69-
}
9+
private const val ANR_TIMEOUT = 5_000L
7010

7111
/**
72-
* Converts a cold flow in a hot flow using the [WhileSubscribedOrRetained] to avoid collections when there is no
73-
* subscribers to the given [scope].
74-
* @param scope the [CoroutineScope] to use to collect the flow.
75-
* @see initialValue to set an initial value to the flow.
76-
* @see [WhileSubscribedOrRetained]
12+
* Default sharing strategy for a flow that will be retained.
13+
* It uses the [SharingStarted.WhileSubscribed] strategy using the ANR timeout to decide if the flow should be
14+
* restarted when there is no subscribers.
7715
*/
78-
fun <T> Flow<T>.stateInRetained(
16+
fun <T> Flow<T>.stateInWhileSubscribed(
7917
scope: CoroutineScope,
8018
initialValue: T,
8119
): StateFlow<T> =
8220
stateIn(
8321
scope = scope,
84-
started = WhileSubscribedOrRetained,
22+
started = SharingStarted.WhileSubscribed(ANR_TIMEOUT),
8523
initialValue = initialValue,
8624
)

Diff for: core/database/src/main/sqldelight/br/com/mob1st/core/database/Schema.sq

+12
Original file line numberDiff line numberDiff line change
@@ -309,3 +309,15 @@ BEGIN
309309
'Update of category_id is not allowed in SeasonalRecurrences'
310310
);
311311
END;
312+
313+
CREATE VIEW category_view AS
314+
SELECT
315+
cat.id AS cat_id, cat.name AS cat_name,
316+
cat.amount AS cat_amount, cat.is_expense AS cat_is_expense,
317+
cat.linked_suggestion_id AS cat_linked_suggestion_id,
318+
cat.created_at AS cat_created_at,
319+
frc.day_of_month AS frc_day_of_month,
320+
src.month AS src_month, src.day AS src_day
321+
FROM Categories AS cat
322+
LEFT JOIN FixedRecurrences AS frc ON cat.id = frc.category_id
323+
LEFT JOIN SeasonalRecurrences AS src ON cat.id = src.category_id;

Diff for: core/design/src/main/kotlin/br/com/mob1st/core/design/atoms/typography/DefaultFontRoles.kt

+11-11
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ data object DefaultFontRoles : Material3Roles {
2323
),
2424
medium = scale.style(
2525
fontFamily = montserrat,
26-
fontWeight = FontWeight.Bold,
26+
fontWeight = FontWeight.ExtraBold,
2727
sizePower = 10,
2828
),
2929
large = scale.style(
3030
fontFamily = montserrat,
31-
fontWeight = FontWeight.Bold,
31+
fontWeight = FontWeight.Black,
3232
sizePower = 12,
3333
),
3434
)
@@ -40,19 +40,19 @@ data object DefaultFontRoles : Material3Roles {
4040
),
4141
medium = scale.style(
4242
fontFamily = montserrat,
43-
fontWeight = FontWeight.SemiBold,
43+
fontWeight = FontWeight.Bold,
4444
sizePower = 6,
4545
),
4646
large = scale.style(
4747
fontFamily = montserrat,
48-
fontWeight = FontWeight.Bold,
48+
fontWeight = FontWeight.ExtraBold,
4949
sizePower = 7,
5050
),
5151
)
5252
override val title = FontRole(
5353
small = scale.style(
5454
fontFamily = montserrat,
55-
fontWeight = FontWeight.Bold,
55+
fontWeight = FontWeight.Black,
5656
sizePower = -1,
5757
),
5858
medium = scale.style(
@@ -68,35 +68,35 @@ data object DefaultFontRoles : Material3Roles {
6868
)
6969
override val body = FontRole(
7070
small = scale.style(
71-
fontFamily = notoSansFlex,
71+
fontFamily = notoSans,
7272
fontWeight = FontWeight.Normal,
7373
sizePower = -1,
7474
),
7575
medium = scale.style(
76-
fontFamily = notoSansFlex,
76+
fontFamily = notoSans,
7777
fontWeight = FontWeight.Medium,
7878
sizePower = 0,
7979
),
8080
large = scale.style(
81-
fontFamily = notoSansFlex,
81+
fontFamily = notoSans,
8282
fontWeight = FontWeight.Bold,
8383
sizePower = 1,
8484
),
8585
)
8686

8787
override val label = FontRole(
8888
small = scale.style(
89-
fontFamily = notoSansFlex,
89+
fontFamily = notoSans,
9090
fontWeight = FontWeight.Light,
9191
sizePower = -2,
9292
),
9393
medium = scale.style(
94-
fontFamily = notoSansFlex,
94+
fontFamily = notoSans,
9595
fontWeight = FontWeight.Bold,
9696
sizePower = -1,
9797
),
9898
large = scale.style(
99-
fontFamily = notoSansFlex,
99+
fontFamily = notoSans,
100100
fontWeight = FontWeight.Bold,
101101
sizePower = 0,
102102
),
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
11
package br.com.mob1st.core.design.atoms.typography
22

3-
import androidx.compose.ui.text.ExperimentalTextApi
43
import androidx.compose.ui.text.font.Font
54
import androidx.compose.ui.text.font.FontFamily
6-
import androidx.compose.ui.text.font.FontStyle
7-
import androidx.compose.ui.text.font.FontVariation
85
import androidx.compose.ui.text.font.FontWeight
96
import br.com.mob1st.core.design.R
107

11-
@OptIn(ExperimentalTextApi::class)
128
internal val montserrat = FontFamily(
139
Font(
14-
R.font.montserrat_flex,
10+
R.font.montserrat__regular,
1511
weight = FontWeight.Normal,
16-
variationSettings = FontVariation.Settings(
17-
FontVariation.weight(FontWeight.Normal.weight),
18-
),
1912
),
2013
Font(
21-
R.font.montserrat_flex,
22-
variationSettings = FontVariation.Settings(
23-
FontVariation.weight(FontWeight.SemiBold.weight),
24-
),
14+
R.font.montserrat__medium,
15+
weight = FontWeight.Medium,
2516
),
2617
Font(
27-
R.font.montserrat_flex,
28-
variationSettings = FontVariation.Settings(
29-
FontVariation.weight(FontWeight.Bold.weight),
30-
),
18+
R.font.montserrat__semi_bold,
19+
weight = FontWeight.SemiBold,
20+
),
21+
Font(
22+
R.font.montserrat__bold,
23+
weight = FontWeight.Bold,
24+
),
25+
Font(
26+
R.font.montserrat__extra_bold,
27+
weight = FontWeight.ExtraBold,
28+
),
29+
Font(
30+
R.font.montserrat__black,
31+
weight = FontWeight.Black,
3132
),
3233
)
3334

34-
@OptIn(ExperimentalTextApi::class)
35-
internal val notoSansFlex = FontFamily(
35+
internal val notoSans = FontFamily(
3636
Font(
37-
R.font.noto_sans_flex,
38-
variationSettings = FontVariation.Settings(FontWeight.Light, FontStyle.Normal),
37+
R.font.noto_sans__light,
38+
weight = FontWeight.Light,
3939
),
4040
Font(
41-
R.font.noto_sans_flex,
42-
variationSettings = FontVariation.Settings(FontWeight.Normal, FontStyle.Normal),
41+
R.font.noto_sans__regular,
42+
weight = FontWeight.Normal,
4343
),
4444
Font(
45-
R.font.noto_sans_flex,
46-
variationSettings = FontVariation.Settings(FontWeight.Medium, FontStyle.Normal),
45+
R.font.noto_sans__medium,
46+
weight = FontWeight.Medium,
4747
),
4848
Font(
49-
R.font.noto_sans_flex,
50-
variationSettings = FontVariation.Settings(FontWeight.SemiBold, FontStyle.Normal),
49+
R.font.noto_sans__semi_bold,
50+
weight = FontWeight.SemiBold,
5151
),
5252
Font(
53-
R.font.noto_sans_flex,
54-
variationSettings = FontVariation.Settings(FontWeight.Bold, FontStyle.Normal),
53+
R.font.noto_sans__bold,
54+
weight = FontWeight.Bold,
5555
),
5656
Font(
57-
R.font.noto_sans_flex,
58-
variationSettings = FontVariation.Settings(FontWeight.ExtraBold, FontStyle.Normal),
57+
R.font.noto_sans__extra_bold,
58+
weight = FontWeight.ExtraBold,
5959
),
6060
Font(
61-
R.font.noto_sans_flex,
62-
variationSettings = FontVariation.Settings(FontWeight.Black, FontStyle.Normal),
61+
R.font.noto_sans__black,
62+
weight = FontWeight.Black,
6363
),
6464
)

Diff for: core/design/src/main/kotlin/br/com/mob1st/core/design/organisms/section/Section.kt

+25-15
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import androidx.compose.foundation.lazy.itemsIndexed
1111
import androidx.compose.material3.ListItem
1212
import androidx.compose.material3.MaterialTheme
1313
import androidx.compose.material3.ProvideTextStyle
14+
import androidx.compose.material3.Surface
1415
import androidx.compose.material3.Text
1516
import androidx.compose.runtime.Composable
1617
import androidx.compose.ui.Alignment
@@ -62,32 +63,41 @@ fun SectionTitle(
6263
.padding(top = Spacings.x6, bottom = Spacings.x2),
6364
contentAlignment = Alignment.CenterStart,
6465
) {
65-
ProvideTextStyle(MaterialTheme.typography.labelLarge) {
66+
ProvideTextStyle(SectionDefaults.titleTextStyle) {
6667
titleContent()
6768
}
6869
}
6970
}
7071

7172
object SectionTitleContentType
7273

74+
internal object SectionDefaults {
75+
val titleTextStyle
76+
@Composable get() = MaterialTheme.typography.labelLarge.copy(
77+
color = MaterialTheme.colorScheme.onSurfaceVariant,
78+
)
79+
}
80+
7381
@Composable
7482
@ThemedPreview
7583
private fun SectionPreview() {
7684
TwoCentsTheme {
77-
LazyColumn(
78-
modifier = Modifier.fillMaxWidth(),
79-
) {
80-
section(
81-
titleContent = {
82-
Text("Title")
83-
},
84-
items = persistentListOf("Item 1", "Item 2", "Item 3"),
85-
itemContent = { _, item ->
86-
ListItem(
87-
headlineContent = { Text(item) },
88-
)
89-
},
90-
)
85+
Surface {
86+
LazyColumn(
87+
modifier = Modifier.fillMaxWidth(),
88+
) {
89+
section(
90+
titleContent = {
91+
Text("Title")
92+
},
93+
items = persistentListOf("Item 1", "Item 2", "Item 3"),
94+
itemContent = { _, item ->
95+
ListItem(
96+
headlineContent = { Text(item) },
97+
)
98+
},
99+
)
100+
}
91101
}
92102
}
93103
}

Diff for: core/design/src/main/res/font/lato_black.ttf

-67.9 KB
Binary file not shown.

Diff for: core/design/src/main/res/font/lato_bold.ttf

-71.6 KB
Binary file not shown.

Diff for: core/design/src/main/res/font/lato_light.ttf

-75.4 KB
Binary file not shown.

Diff for: core/design/src/main/res/font/lato_regular.ttf

-73.4 KB
Binary file not shown.

Diff for: core/design/src/main/res/font/montserrat__black.ttf

194 KB
Binary file not shown.

Diff for: core/design/src/main/res/font/montserrat__bold.ttf

193 KB
Binary file not shown.
195 KB
Binary file not shown.

Diff for: core/design/src/main/res/font/montserrat__medium.ttf

193 KB
Binary file not shown.
193 KB
Binary file not shown.
193 KB
Binary file not shown.

Diff for: core/design/src/main/res/font/montserrat_flex.ttf

-385 KB
Binary file not shown.

Diff for: core/design/src/main/res/font/noto_sans__black.ttf

570 KB
Binary file not shown.

Diff for: core/design/src/main/res/font/noto_sans__bold.ttf

569 KB
Binary file not shown.
570 KB
Binary file not shown.

Diff for: core/design/src/main/res/font/noto_sans__light.ttf

570 KB
Binary file not shown.

Diff for: core/design/src/main/res/font/noto_sans__medium.ttf

569 KB
Binary file not shown.

Diff for: core/design/src/main/res/font/noto_sans__regular.ttf

569 KB
Binary file not shown.
570 KB
Binary file not shown.

Diff for: core/design/src/main/res/font/noto_sans_flex.ttf

-2.38 MB
Binary file not shown.

Diff for: core/design/src/main/res/font/open_sans_flex.ttf

-517 KB
Binary file not shown.

Diff for: core/design/src/main/res/font/roboto_mono_flex.ttf

-180 KB
Binary file not shown.

Diff for: core/design/src/main/res/font/titillium_web_bold.ttf

-52.6 KB
Binary file not shown.
-56 KB
Binary file not shown.
-55.4 KB
Binary file not shown.

Diff for: features/dev/impl/src/main/kotlin/br/com/mob1st/features/dev/impl/presentation/menu/DevMenuViewModel.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package br.com.mob1st.features.dev.impl.presentation.menu
22

33
import androidx.lifecycle.ViewModel
44
import androidx.lifecycle.viewModelScope
5-
import br.com.mob1st.core.androidx.flows.stateInRetained
5+
import br.com.mob1st.core.androidx.flows.stateInWhileSubscribed
66
import br.com.mob1st.core.state.contracts.NavigationDelegate
77
import br.com.mob1st.core.state.contracts.NavigationManager
88
import br.com.mob1st.core.state.contracts.UiStateOutputManager
@@ -26,7 +26,7 @@ internal class DevMenuViewModel(
2626
SnackbarManager<DevMenuSnackbar> by SnackbarDelegate(),
2727
DialogManager<CommonError> by DialogDelegate() {
2828
override val uiStateOutput: StateFlow<DevMenuUiState> = getDevMenu()
29-
.stateInRetained(
29+
.stateInWhileSubscribed(
3030
scope = viewModelScope,
3131
initialValue = DevMenuUiState.Empty,
3232
)

Diff for: features/dev/impl/src/test/kotlin/br/com/mob1st/features/dev/impl/presentation/menu/DevMenuViewModelTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import br.com.mob1st.features.dev.impl.domain.GetDevMenuUseCase
77
import br.com.mob1st.features.dev.publicapi.domain.BackendEnvironment
88
import br.com.mob1st.features.dev.publicapi.presentation.DevSettingsNavTarget
99
import br.com.mob1st.features.utils.errors.CommonError
10-
import br.com.mob1st.tests.featuresutils.ViewModelTestExtension
10+
import br.com.mob1st.tests.featuresutils.MainDispatcherTestExtension
1111
import io.mockk.every
1212
import io.mockk.mockk
1313
import kotlinx.collections.immutable.persistentListOf
@@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test
1818
import org.junit.jupiter.api.extension.ExtendWith
1919
import kotlin.test.assertEquals
2020

21-
@ExtendWith(ViewModelTestExtension::class)
21+
@ExtendWith(MainDispatcherTestExtension::class)
2222
internal class DevMenuViewModelTest {
2323
private lateinit var getDevMenuUseCase: GetDevMenuUseCase
2424
private lateinit var stateHolder: DevMenuUiStateHolder

0 commit comments

Comments
 (0)