Skip to content

Commit 62408e9

Browse files
committed
feat: Show Cat seed on input dialog
Signed-off-by: Hu Shenghao <dede.hu@qq.com>
1 parent fa210d5 commit 62408e9

File tree

2 files changed

+40
-25
lines changed

2 files changed

+40
-25
lines changed

feature/cat-editor/src/main/java/com/dede/android_eggs/cat_editor/CatEditorScreen.kt

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import androidx.compose.animation.fadeIn
99
import androidx.compose.animation.fadeOut
1010
import androidx.compose.animation.slideInVertically
1111
import androidx.compose.animation.slideOutVertically
12-
import androidx.compose.foundation.background
1312
import androidx.compose.foundation.layout.Box
14-
import androidx.compose.foundation.layout.Column
13+
import androidx.compose.foundation.layout.Row
1514
import androidx.compose.foundation.layout.Spacer
1615
import androidx.compose.foundation.layout.fillMaxSize
1716
import androidx.compose.foundation.layout.padding
@@ -20,19 +19,19 @@ import androidx.compose.material.icons.Icons
2019
import androidx.compose.material.icons.automirrored.rounded.ArrowBack
2120
import androidx.compose.material.icons.automirrored.rounded.ArrowForward
2221
import androidx.compose.material.icons.rounded.ContentCopy
23-
import androidx.compose.material.icons.rounded.Edit
2422
import androidx.compose.material.icons.rounded.GridOff
2523
import androidx.compose.material.icons.rounded.GridOn
2624
import androidx.compose.material.icons.rounded.MoreVert
2725
import androidx.compose.material.icons.rounded.Palette
2826
import androidx.compose.material.icons.rounded.Refresh
2927
import androidx.compose.material.icons.rounded.Save
3028
import androidx.compose.material3.BottomAppBar
29+
import androidx.compose.material3.Card
30+
import androidx.compose.material3.CardDefaults.cardColors
3131
import androidx.compose.material3.CenterAlignedTopAppBar
3232
import androidx.compose.material3.ExperimentalMaterial3Api
3333
import androidx.compose.material3.Icon
3434
import androidx.compose.material3.IconButton
35-
import androidx.compose.material3.MaterialTheme
3635
import androidx.compose.material3.MaterialTheme.colorScheme
3736
import androidx.compose.material3.Scaffold
3837
import androidx.compose.material3.Text
@@ -59,6 +58,7 @@ import com.dede.android_eggs.cat_editor.CaptureControllerDelegate.Companion.reme
5958
import com.dede.android_eggs.cat_editor.CatEditorRecords.Companion.rememberCatEditorRecords
6059
import com.dede.android_eggs.navigation.EasterEggsDestination
6160
import com.dede.android_eggs.navigation.LocalNavController
61+
import com.dede.android_eggs.ui.composes.icons.rounded.Cat
6262
import com.dede.basic.copy
6363
import com.dede.basic.toast
6464
import com.dede.basic.utils.ShareCatUtils
@@ -109,7 +109,7 @@ fun CatEditorScreen() {
109109
Icon(
110110
imageVector = Icons.AutoMirrored.Rounded.ArrowBack,
111111
contentDescription = null,
112-
tint = MaterialTheme.colorScheme.onSurface
112+
tint = colorScheme.onSurface
113113
)
114114
}
115115
},
@@ -291,35 +291,39 @@ fun CatEditorScreen() {
291291
visible = moreOptionsVisible,
292292
modifier = Modifier
293293
.align(Alignment.BottomEnd)
294-
.padding(vertical = 14.dp, horizontal = 10.dp),
294+
.padding(vertical = 12.dp, horizontal = 14.dp),
295295
label = "More Options Visibility",
296296
enter = fadeIn(animationSpec = tween(220)) +
297297
slideInVertically(animationSpec = tween(220)) { it / 2 },
298298
exit = fadeOut(animationSpec = tween(220)) +
299299
slideOutVertically(animationSpec = tween(220)) { it / 2 }
300300
) {
301-
Column(
302-
modifier = Modifier
303-
.background(colorScheme.surfaceColorAtElevation(4.dp), CircleShape)
304-
.padding(4.dp)
301+
Card(
302+
shape = CircleShape,
303+
colors = cardColors(containerColor = colorScheme.surfaceColorAtElevation(4.dp))
305304
) {
305+
Row(modifier = Modifier.padding(4.dp)) {
306+
IconButton(onClick = {
307+
context.copy(catSeed.toString())
308+
}) {
309+
Icon(
310+
imageVector = Icons.Rounded.ContentCopy,
311+
contentDescription = stringResource(android.R.string.copy)
312+
)
313+
}
306314

307-
IconButton(onClick = {
308-
context.copy(catSeed.toString())
309-
}) {
310-
Icon(imageVector = Icons.Rounded.ContentCopy, contentDescription = null)
311-
}
312-
313-
IconButton(onClick = {
314-
inputSeedDialogState.value = true
315-
}) {
316-
Icon(imageVector = Icons.Rounded.Edit, contentDescription = null)
317-
}
315+
IconButton(onClick = {
316+
moreOptionsVisible = false
317+
inputSeedDialogState.value = true
318+
}) {
319+
Icon(imageVector = Icons.Rounded.Cat, contentDescription = null)
320+
}
318321

319-
IconButton(onClick = {
320-
updateCatSeed(Utilities.randomSeed())
321-
}) {
322-
Icon(imageVector = Icons.Rounded.Refresh, contentDescription = null)
322+
IconButton(onClick = {
323+
updateCatSeed(Utilities.randomSeed())
324+
}) {
325+
Icon(imageVector = Icons.Rounded.Refresh, contentDescription = null)
326+
}
323327
}
324328
}
325329
}

feature/cat-editor/src/main/java/com/dede/android_eggs/cat_editor/CatSeedInputDialog.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import androidx.compose.animation.fadeIn
55
import androidx.compose.animation.fadeOut
66
import androidx.compose.animation.scaleIn
77
import androidx.compose.animation.scaleOut
8+
import androidx.compose.animation.slideInVertically
9+
import androidx.compose.animation.slideOutVertically
810
import androidx.compose.foundation.text.KeyboardActions
911
import androidx.compose.foundation.text.KeyboardOptions
1012
import androidx.compose.material.icons.Icons
@@ -112,6 +114,15 @@ fun CatSeedInputDialog(
112114
}
113115
},
114116
isError = inputError,
117+
supportingText = {
118+
AnimatedVisibility(
119+
visible = inputSeedText.isNotEmpty(),
120+
enter = fadeIn() + slideInVertically(),
121+
exit = fadeOut() + slideOutVertically(),
122+
) {
123+
Text(text = "# ${Utilities.string2Seed(inputSeedText)}")
124+
}
125+
},
115126
label = {
116127
Text(text = stringResource(R.string.cat_editor_input_seed))
117128
},

0 commit comments

Comments
 (0)