Skip to content

Commit 24e231f

Browse files
authored
Merge branch 'master' into add-claude-github-actions-1765328398459
2 parents afa3fd6 + 8873f41 commit 24e231f

File tree

14 files changed

+690
-191
lines changed

14 files changed

+690
-191
lines changed

app/src/main/java/to/bitkit/di/ViewModelModule.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import dagger.Module
55
import dagger.Provides
66
import dagger.hilt.InstallIn
77
import dagger.hilt.components.SingletonComponent
8+
import kotlinx.coroutines.CoroutineScope
9+
import to.bitkit.ui.shared.toast.ToastQueueManager
810
import javax.inject.Singleton
911

1012
@Module
@@ -15,4 +17,9 @@ object ViewModelModule {
1517
fun provideFirebaseMessaging(): FirebaseMessaging {
1618
return FirebaseMessaging.getInstance()
1719
}
20+
21+
@Provides
22+
fun provideToastManagerProvider(): (CoroutineScope) -> ToastQueueManager {
23+
return ::ToastQueueManager
24+
}
1825
}

app/src/main/java/to/bitkit/ui/ContentView.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,6 @@ private fun NavGraphBuilder.activityItem(
10891089
}
10901090
composableWithDefaultTransitions<Routes.ActivityExplore> {
10911091
ActivityExploreScreen(
1092-
listViewModel = activityListViewModel,
10931092
route = it.toRoute(),
10941093
onBackClick = { navController.popBackStack() },
10951094
)

app/src/main/java/to/bitkit/ui/MainActivity.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,13 @@ class MainActivity : FragmentActivity() {
166166
}
167167
}
168168

169+
val currentToast by appViewModel.currentToast.collectAsStateWithLifecycle()
169170
ToastOverlay(
170-
toast = appViewModel.currentToast,
171+
toast = currentToast,
171172
hazeState = hazeState,
172-
onDismiss = {
173-
appViewModel.hideToast()
174-
}
173+
onDismiss = { appViewModel.hideToast() },
174+
onDragStart = { appViewModel.pauseToast() },
175+
onDragEnd = { appViewModel.resumeToast() }
175176
)
176177

177178
val transactionSheetDetails by appViewModel.transactionSheet.collectAsStateWithLifecycle()

app/src/main/java/to/bitkit/ui/components/ActivityBanner.kt

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import to.bitkit.R
3737
import to.bitkit.models.ActivityBannerType
3838
import to.bitkit.ui.shared.util.clickableAlpha
3939
import to.bitkit.ui.shared.util.outerGlow
40+
import to.bitkit.ui.theme.AppThemeSurface
4041
import to.bitkit.ui.theme.Colors
4142

4243
private const val GLOW_ANIMATION_MILLIS = 1200
@@ -174,18 +175,20 @@ fun ActivityBanner(
174175
@Preview(showSystemUi = true)
175176
@Composable
176177
private fun Preview() {
177-
LazyColumn(
178-
verticalArrangement = Arrangement.spacedBy(4.dp),
179-
modifier = Modifier.fillMaxSize(),
180-
) {
181-
items(items = ActivityBannerType.entries) { item ->
182-
ActivityBanner(
183-
gradientColor = item.color,
184-
title = stringResource(R.string.activity_banner__transfer_in_progress),
185-
icon = item.icon,
186-
onClick = {},
187-
modifier = Modifier.fillMaxWidth()
188-
)
178+
AppThemeSurface {
179+
LazyColumn(
180+
verticalArrangement = Arrangement.spacedBy(4.dp),
181+
modifier = Modifier.fillMaxSize(),
182+
) {
183+
items(items = ActivityBannerType.entries) { item ->
184+
ActivityBanner(
185+
gradientColor = item.color,
186+
title = stringResource(R.string.activity_banner__transfer_in_progress),
187+
icon = item.icon,
188+
onClick = {},
189+
modifier = Modifier.fillMaxWidth()
190+
)
191+
}
189192
}
190193
}
191194
}

app/src/main/java/to/bitkit/ui/components/ToastView.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import androidx.compose.animation.SizeTransform
55
import androidx.compose.animation.core.Animatable
66
import androidx.compose.animation.core.Spring
77
import androidx.compose.animation.core.spring
8+
import androidx.compose.animation.core.tween
89
import androidx.compose.animation.fadeIn
910
import androidx.compose.animation.fadeOut
1011
import androidx.compose.animation.slideInVertically
@@ -126,7 +127,14 @@ fun ToastView(
126127
val isHorizontalSwipe = horizontalSwipeDistance > verticalSwipeDistance
127128

128129
if (isHorizontalSwipe && horizontalSwipeDistance > dismissThreshold.toPx()) {
129-
// Horizontal swipe dismiss
130+
// Horizontal swipe dismiss - animate off-screen horizontally
131+
val swipeDirection = if (dragOffsetX.value > 0) 1f else -1f
132+
val targetOffsetX = swipeDirection * 1200.dp.toPx()
133+
134+
dragOffsetX.animateTo(
135+
targetValue = targetOffsetX,
136+
animationSpec = tween(durationMillis = 200)
137+
)
130138
onDismiss()
131139
} else if (!isHorizontalSwipe && dragOffsetY.value < -dismissThreshold.toPx()) {
132140
// Vertical swipe up dismiss
@@ -285,9 +293,9 @@ private fun ToastHost(
285293
@Composable
286294
fun ToastOverlay(
287295
toast: Toast?,
296+
onDismiss: () -> Unit,
288297
modifier: Modifier = Modifier,
289298
hazeState: HazeState = rememberHazeState(blurEnabled = true),
290-
onDismiss: () -> Unit,
291299
onDragStart: () -> Unit = {},
292300
onDragEnd: () -> Unit = {},
293301
) {
@@ -312,7 +320,6 @@ private fun ToastViewPreview() {
312320
ScreenColumn(
313321
verticalArrangement = Arrangement.spacedBy(16.dp),
314322
) {
315-
316323
ToastView(
317324
toast = Toast(
318325
type = Toast.ToastType.WARNING,

app/src/main/java/to/bitkit/ui/screens/wallets/HomeViewModel.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import kotlinx.coroutines.flow.MutableStateFlow
88
import kotlinx.coroutines.flow.StateFlow
99
import kotlinx.coroutines.flow.asStateFlow
1010
import kotlinx.coroutines.flow.combine
11-
import kotlinx.coroutines.flow.distinctUntilChanged
1211
import kotlinx.coroutines.flow.map
1312
import kotlinx.coroutines.flow.update
1413
import kotlinx.coroutines.launch
@@ -217,14 +216,13 @@ class HomeViewModel @Inject constructor(
217216

218217
private suspend fun createBannersFlow() {
219218
transferRepo.activeTransfers
220-
.distinctUntilChanged()
221219
.collect { transfers ->
222220
val banners = listOfNotNull(
223221
ActivityBannerType.SPENDING.takeIf {
224-
transfers.any { it.type == TransferType.TO_SPENDING || it.type == TransferType.MANUAL_SETUP }
222+
transfers.any { it.type.isToSpending() }
225223
},
226224
ActivityBannerType.SAVINGS.takeIf {
227-
transfers.any { it.type == TransferType.COOP_CLOSE || it.type == TransferType.FORCE_CLOSE }
225+
transfers.any { it.type.isToSavings() }
228226
},
229227
)
230228
_uiState.update { it.copy(banners = banners) }

0 commit comments

Comments
 (0)