-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adapted rust api changes on android side to show dot and blockies icons
- Loading branch information
1 parent
4cd7d31
commit d88e258
Showing
30 changed files
with
181 additions
and
230 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
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
121 changes: 0 additions & 121 deletions
121
android/src/main/java/io/parity/signer/components/IdentIcon.kt
This file was deleted.
Oops, something went wrong.
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
91 changes: 91 additions & 0 deletions
91
android/src/main/java/io/parity/signer/components/networkicon/IdentIconImage.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,91 @@ | ||
package io.parity.signer.components.networkicon | ||
|
||
import android.content.res.Configuration | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import io.parity.signer.components.networkicon.blockies.BlockiesIcon | ||
import io.parity.signer.components.networkicon.dot.DotIcon | ||
import io.parity.signer.ui.helpers.PreviewData | ||
import io.parity.signer.ui.theme.SignerNewTheme | ||
import io.parity.signer.uniffi.Identicon | ||
|
||
/** | ||
* Just draw a standard IdentIcon used everywhere, with standard size | ||
*/ | ||
@Composable | ||
fun IdentIconImage( | ||
identIcon: Identicon, | ||
modifier: Modifier = Modifier, | ||
size: Dp = 28.dp | ||
) { | ||
when (identIcon) { | ||
is Identicon.Blockies -> { | ||
BlockiesIcon( | ||
seed = identIcon.identity, | ||
preferedSize = size, | ||
modifier = modifier, | ||
) | ||
} | ||
|
||
is Identicon.Dots -> { | ||
DotIcon(seed = identIcon.identity, | ||
size = size, | ||
modifier = modifier, | ||
) | ||
} | ||
// is ImageContent.Svg -> {//will be used for another type of icons | ||
// val context = LocalContext.current | ||
// val painter = rememberAsyncImagePainter( | ||
// model = ImageRequest.Builder(context) | ||
// .decoderFactory(SvgDecoder.Factory()) | ||
// .data(identIcon.toByteArray()) | ||
// .size(Size.ORIGINAL) // Set the target size to load the image at. | ||
// .build(), | ||
// ) | ||
// Image( | ||
// painter = painter, | ||
// contentDescription = stringResource(R.string.description_identicon), | ||
// modifier = modifier | ||
// .size(size) | ||
// .clip(CircleShape) | ||
// ) | ||
// } | ||
} | ||
} | ||
|
||
/** | ||
* As svg parsed async and in preview Dispatchers.IO is not working | ||
* run preview on device to see it. | ||
* Consider creating custom coil.ImageLoader with main ui fetch and parse dispatchers. Maybe for preview only. | ||
*/ | ||
@Preview( | ||
name = "light", group = "themes", uiMode = Configuration.UI_MODE_NIGHT_NO, | ||
showBackground = true, backgroundColor = 0xFFFFFFFF, | ||
) | ||
@Preview( | ||
name = "dark", group = "themes", uiMode = Configuration.UI_MODE_NIGHT_YES, | ||
showBackground = true, backgroundColor = 0xFF000000, | ||
) | ||
@Composable | ||
private fun PreviewIdentIcon() { | ||
SignerNewTheme { | ||
val iconDot = PreviewData.Identicon.dotIcon | ||
val iconBlockies = PreviewData.Identicon.blockiesIcon | ||
|
||
Column( | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
) { | ||
IdentIconImage(iconDot) | ||
IdentIconImage(iconBlockies) | ||
IdentIconImage(iconDot, size = 18.dp) | ||
IdentIconImage(iconBlockies, size = 18.dp) | ||
IdentIconImage(iconDot, size = 56.dp) | ||
IdentIconImage(iconBlockies, size = 56.dp) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.