generated from michaelbel/android-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
249cf0c
commit bd793e9
Showing
7 changed files
with
159 additions
and
63 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
composeApp/src/commonMain/composeResources/drawable/ic_close_24.xml
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,11 @@ | ||
<vector | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:tint="#FFFFFF" | ||
android:viewportHeight="24" | ||
android:viewportWidth="24"> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z" /> | ||
</vector> |
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
19 changes: 19 additions & 0 deletions
19
composeApp/src/commonMain/kotlin/org/michaelbel/mobiledevemoji/ktx/ModifierKtx.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,19 @@ | ||
@file:Suppress("unused") | ||
|
||
package org.michaelbel.mobiledevemoji.ktx | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.interaction.MutableInteractionSource | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.composed | ||
|
||
fun Modifier.clickableWithoutRipple( | ||
block: () -> Unit | ||
): Modifier = composed { | ||
clickable( | ||
interactionSource = remember { MutableInteractionSource() }, | ||
indication = null, | ||
onClick = { block() } | ||
) | ||
} |
55 changes: 0 additions & 55 deletions
55
composeApp/src/commonMain/kotlin/org/michaelbel/mobiledevemoji/ui/IconPreviewBox.kt
This file was deleted.
Oops, something went wrong.
112 changes: 112 additions & 0 deletions
112
composeApp/src/commonMain/kotlin/org/michaelbel/mobiledevemoji/ui/IconPreviewDialog.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,112 @@ | ||
@file:OptIn(ExperimentalMaterial3Api::class) | ||
|
||
package org.michaelbel.mobiledevemoji.ui | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.layout.wrapContentHeight | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material.Icon | ||
import androidx.compose.material.IconButton | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.ModalBottomSheet | ||
import androidx.compose.material3.SheetValue | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.rememberModalBottomSheetState | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.rememberCoroutineScope | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.draw.shadow | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.unit.dp | ||
import kotlinx.coroutines.launch | ||
import org.jetbrains.compose.resources.painterResource | ||
import org.michaelbel.mobiledevemoji.data.CloseIconRes | ||
import org.michaelbel.mobiledevemoji.data.Emoji | ||
|
||
@Composable | ||
fun IconPreviewDialog( | ||
emoji: Emoji, | ||
onDismissRequest: () -> Unit, | ||
modifier: Modifier | ||
) { | ||
val sheetState = rememberModalBottomSheetState( | ||
skipPartiallyExpanded = true, | ||
confirmValueChange = { sheetValue -> | ||
if (sheetValue == SheetValue.Hidden) { | ||
onDismissRequest() | ||
} | ||
true | ||
} | ||
) | ||
val scope = rememberCoroutineScope() | ||
|
||
fun hide() { | ||
scope.launch { sheetState.hide() } | ||
} | ||
|
||
ModalBottomSheet( | ||
onDismissRequest = onDismissRequest, | ||
sheetState = sheetState, | ||
containerColor = MaterialTheme.colorScheme.surface | ||
) { | ||
Box( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.wrapContentHeight() | ||
) { | ||
Column( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.wrapContentHeight(), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Box( | ||
modifier = Modifier | ||
.padding(top = 24.dp) | ||
.shadow( | ||
elevation = 8.dp, | ||
shape = RoundedCornerShape(72.dp) | ||
) | ||
.clip(RoundedCornerShape(72.dp)) | ||
.size(300.dp) | ||
) { | ||
SvgIcon( | ||
painter = emoji.painter, | ||
modifier = Modifier.size(300.dp) | ||
) | ||
} | ||
|
||
Text( | ||
text = emoji.emojiResponse.name, | ||
modifier = Modifier.padding(start = 16.dp, top = 16.dp, end = 16.dp, bottom = 48.dp), | ||
textAlign = TextAlign.Center, | ||
color = MaterialTheme.colorScheme.onBackground, | ||
style = MaterialTheme.typography.headlineMedium | ||
) | ||
} | ||
|
||
IconButton( | ||
onClick = ::hide, | ||
modifier = Modifier | ||
.padding(end = 8.dp) | ||
.align(Alignment.TopEnd) | ||
) { | ||
Icon( | ||
painter = painterResource(CloseIconRes), | ||
contentDescription = null, | ||
tint = Color.Unspecified | ||
) | ||
} | ||
} | ||
} | ||
} |
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