Skip to content

Commit

Permalink
[#1420] Testing Servers Responses + redesign (#1536)
Browse files Browse the repository at this point in the history
* Dependency injection implementation

* Code cleanup

* Code cleanup

* Test hotfix

* [#1420] Choose Server UI refactor

* [#1420] UI refactor

* [#1420] Code cleanup

* [#1420] SDK integration

* [#1420] Choose server redesign

Closes #1420

* [#1420] Code cleanup

Closes #1420

* #1420 Design updates

Closes #1420

* #1420 Design updates

Closes #1420

* #1420 Code cleanup

Closes #1420

* #1420 Code cleanup

Closes #1420

* #1420 Code cleanup

Closes #1420

* #1420 Design hotfixes

Closes #1420

* #1420 Design hotfixes

Closes #1420

* #1420 Code cleanup

Closes #1420

* #1420 Design hotfixes

Closes #1420

* #1420 Design hotfixes

Closes #1420

* Remove unnecessary supression

* Remove unnecessary dependency

- We link these by the command api(libs.bundles.koin) above

* [#1420] Code cleanup

Closes #1420

* Changelogs update

---------

Co-authored-by: Honza <[email protected]>
  • Loading branch information
Milan-Cerovsky and HonzaR authored Sep 11, 2024
1 parent 85a545b commit b75836f
Show file tree
Hide file tree
Showing 57 changed files with 2,305 additions and 872 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this application adheres to [Semantic Versioning](https://semver.org/spec/v2
### Added
- Transaction resubmission feature has been added. It periodically searches for unmined sent transactions that
are still within their expiry window and resubmits them if there are any.
- The Choose server screen now provides a new search for the three fastest servers feature

### Changed
- Choose server screen has been redesigned

## [1.1.7 (718)] - 2024-09-06

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package co.electriccoin.zcash.app

import co.electriccoin.zcash.crash.android.GlobalCrashReporter
import co.electriccoin.zcash.di.coreModule
import co.electriccoin.zcash.di.providerModule
import co.electriccoin.zcash.di.repositoryModule
import co.electriccoin.zcash.di.useCaseModule
import co.electriccoin.zcash.di.viewModelModule
Expand Down Expand Up @@ -31,6 +32,7 @@ class ZcashApplication : CoroutineApplication() {
androidContext(this@ZcashApplication)
modules(
coreModule,
providerModule,
repositoryModule,
useCaseModule,
viewModelModule
Expand Down
8 changes: 6 additions & 2 deletions docs/whatsNew/WHATS_NEW_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ directly impact users rather than highlighting other key architectural updates.*
## [Unreleased]

### Added
- Transaction resubmission feature has been added. It periodically searches for unmined sent transactions that are
still within their expiry window and resubmits them if there are any.
- Transaction resubmission feature has been added. It periodically searches for unmined sent transactions that
are still within their expiry window and resubmits them if there are any.
- The Choose server screen now provides a new search for the three fastest servers feature

### Changed
- Choose server screen has been redesigned

## [1.1.7 (718)] - 2024-09-06

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package co.electriccoin.zcash.ui.design.component

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.design.util.StringResource
import co.electriccoin.zcash.ui.design.util.getValue
import co.electriccoin.zcash.ui.design.util.stringRes

@Composable
fun Badge(
text: StringResource,
modifier: Modifier = Modifier,
shape: Shape = CircleShape,
color: Color = ZcashTheme.zashiColors.utilitySuccess50,
border: BorderStroke = BorderStroke(1.dp, ZcashTheme.zashiColors.utilitySuccess200),
) {
Surface(
modifier = modifier,
shape = shape,
color = color,
border = border
) {
Box(
modifier = Modifier.padding(horizontal = 10.dp, vertical = 4.dp)
) {
Text(
text = text.getValue(),
style = ZcashTheme.extendedTypography.transactionItemStyles.contentMedium,
fontSize = 14.sp,
color = ZcashTheme.zashiColors.utilitySuccess700
)
}
}
}

@Preview
@Composable
private fun BadgePreview() =
ZcashTheme {
Badge(text = stringRes("Badge"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.design.theme.internal.ButtonColors
import co.electriccoin.zcash.ui.design.theme.internal.DarkTertiaryButtonColors
import co.electriccoin.zcash.ui.design.theme.internal.LightTertiaryButtonColors
import co.electriccoin.zcash.ui.design.util.StringResource

@Preview
@Composable
Expand Down Expand Up @@ -407,20 +408,18 @@ fun Modifier.shadow(
}
)

private enum class ButtonState { Pressed, Idle }

// TODO [#1346]: Rework not-recommended composed{}
// TODO [#1346]: https://github.com/Electric-Coin-Company/zashi-android/issues/1346
@Suppress("ModifierComposed")
fun Modifier.translationClick(
translationX: Dp = 0.dp,
translationY: Dp = 0.dp
) = composed {
var buttonState by remember { mutableStateOf(ButtonState.Idle) }
var buttonMode by remember { mutableStateOf(ButtonMode.Idle) }

val translationXAnimated by animateFloatAsState(
targetValue =
if (buttonState == ButtonState.Pressed) {
if (buttonMode == ButtonMode.Pressed) {
translationX.value
} else {
0f
Expand All @@ -433,7 +432,7 @@ fun Modifier.translationClick(
)
val translationYAnimated by animateFloatAsState(
targetValue =
if (buttonState == ButtonState.Pressed) {
if (buttonMode == ButtonMode.Pressed) {
translationY.value
} else {
0f
Expand All @@ -450,16 +449,25 @@ fun Modifier.translationClick(
this.translationX = translationXAnimated
this.translationY = translationYAnimated
}
.pointerInput(buttonState) {
.pointerInput(buttonMode) {
awaitPointerEventScope {
buttonState =
if (buttonState == ButtonState.Pressed) {
buttonMode =
if (buttonMode == ButtonMode.Pressed) {
waitForUpOrCancellation()
ButtonState.Idle
ButtonMode.Idle
} else {
awaitFirstDown(false)
ButtonState.Pressed
ButtonMode.Pressed
}
}
}
}

private enum class ButtonMode { Pressed, Idle }

data class ButtonState(
val text: StringResource,
val isEnabled: Boolean = true,
val isLoading: Boolean = false,
val onClick: () -> Unit = {},
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogProperties
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.design.util.StringResource
import co.electriccoin.zcash.ui.design.util.getValue

@Preview
@Composable
Expand Down Expand Up @@ -141,6 +143,28 @@ fun AppAlertDialog(
)
}

@Composable
@Suppress("LongParameterList")
fun AppAlertDialog(
state: AlertDialogState,
modifier: Modifier = Modifier,
icon: ImageVector? = null,
properties: DialogProperties = DialogProperties()
) {
AppAlertDialog(
modifier = modifier,
onDismissRequest = state.onDismissRequest,
confirmButtonText = state.confirmButtonState?.text?.getValue(),
onConfirmButtonClick = state.confirmButtonState?.onClick,
dismissButtonText = state.dismissButtonState?.text?.getValue(),
onDismissButtonClick = state.dismissButtonState?.onClick,
icon = icon,
title = state.title.getValue(),
text = state.text.getValue(),
properties = properties,
)
}

@Preview
@Composable
private fun NavigationButtonPreview() {
Expand Down Expand Up @@ -187,3 +211,11 @@ private fun NavigationButton(
)
}
}

data class AlertDialogState(
val title: StringResource,
val text: StringResource,
val confirmButtonState: ButtonState? = null,
val dismissButtonState: ButtonState? = null,
val onDismissRequest: (() -> Unit)? = null,
)
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package co.electriccoin.zcash.ui.design.component

import androidx.annotation.RawRes
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import co.electriccoin.zcash.ui.design.R
import com.airbnb.lottie.compose.LottieAnimation
Expand All @@ -14,18 +16,18 @@ import com.airbnb.lottie.compose.animateLottieCompositionAsState
import com.airbnb.lottie.compose.rememberLottieComposition

@Composable
fun LottieProgress(modifier: Modifier = Modifier) {
val composition by rememberLottieComposition(
LottieCompositionSpec.RawRes(
if (isSystemInDarkTheme()) R.raw.lottie_loading_white else R.raw.lottie_loading
)
)
fun LottieProgress(
modifier: Modifier = Modifier,
size: Dp = 16.dp,
@RawRes loadingRes: Int = if (isSystemInDarkTheme()) R.raw.lottie_loading_white else R.raw.lottie_loading
) {
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(loadingRes))
val progress by animateLottieCompositionAsState(
iterations = LottieConstants.IterateForever,
composition = composition
)
LottieAnimation(
modifier = modifier.size(16.dp),
modifier = modifier.size(size),
composition = composition,
progress = { progress },
maintainOriginalImageBounds = true
Expand Down
Loading

0 comments on commit b75836f

Please sign in to comment.