-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: sketching discard confirmation (WPB-6960) #2903
Merged
yamilmedina
merged 10 commits into
feat/sketching-color-picking
from
feat/sketching-discard-confirmation
Apr 17, 2024
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3a7de47
feat: confirm on exit
yamilmedina 60c46a0
feat: confirm on exit, reinit
yamilmedina 1ad6a65
feat: confirm on exit, detkt
yamilmedina 3156dc2
feat: confirm on exit, detkt
yamilmedina 18903e4
feat: extract dialog to file
yamilmedina 52df953
feat: extract dialog to file
yamilmedina 5efe21b
feat: commons dialog
yamilmedina 0339332
feat: test coverage
yamilmedina 592a9a9
feat: wrong name in file
yamilmedina ebdf6c0
feat: preview to components
yamilmedina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
174 changes: 174 additions & 0 deletions
174
app/src/main/kotlin/com/wire/android/ui/common/PrevieWireDialog.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,174 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.android.ui.common | ||
|
||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.ExperimentalComposeUiApi | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.SpanStyle | ||
import androidx.compose.ui.text.buildAnnotatedString | ||
import androidx.compose.ui.text.input.TextFieldValue | ||
import androidx.compose.ui.text.withStyle | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import com.wire.android.ui.common.button.WireButtonState | ||
import com.wire.android.ui.common.textfield.WirePasswordTextField | ||
import com.wire.android.ui.theme.WireTheme | ||
import com.wire.android.ui.theme.wireTypography | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun PreviewWireDialog() { | ||
var password by remember { mutableStateOf(TextFieldValue("")) } | ||
WireTheme { | ||
Box( | ||
contentAlignment = Alignment.Center, | ||
modifier = Modifier.fillMaxWidth() | ||
) { | ||
WireDialogContent( | ||
optionButton1Properties = WireDialogButtonProperties( | ||
text = "OK", | ||
onClick = { }, | ||
type = WireDialogButtonType.Primary, | ||
state = if (password.text.isEmpty()) WireButtonState.Disabled else WireButtonState.Error, | ||
), | ||
dismissButtonProperties = WireDialogButtonProperties( | ||
text = "Cancel", | ||
onClick = { } | ||
), | ||
title = "title", | ||
text = buildAnnotatedString { | ||
val style = SpanStyle( | ||
color = colorsScheme().onBackground, | ||
fontWeight = MaterialTheme.wireTypography.body01.fontWeight, | ||
fontSize = MaterialTheme.wireTypography.body01.fontSize, | ||
fontFamily = MaterialTheme.wireTypography.body01.fontFamily, | ||
fontStyle = MaterialTheme.wireTypography.body01.fontStyle | ||
) | ||
withStyle(style) { append("text\nsecond line\nthirdLine\nfourth line\nfifth line\nsixth line\nseventh line") } | ||
}, | ||
) { | ||
WirePasswordTextField( | ||
value = password, | ||
onValueChange = { password = it }, | ||
autofill = false | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@OptIn(ExperimentalComposeUiApi::class) | ||
@Preview(showBackground = true) | ||
@Composable | ||
fun PreviewWireDialogWith2OptionButtons() { | ||
var password by remember { mutableStateOf(TextFieldValue("")) } | ||
WireTheme { | ||
Box( | ||
contentAlignment = Alignment.Center, | ||
modifier = Modifier.fillMaxWidth() | ||
) { | ||
WireDialogContent( | ||
optionButton1Properties = WireDialogButtonProperties( | ||
text = "OK", | ||
onClick = { }, | ||
type = WireDialogButtonType.Primary, | ||
state = if (password.text.isEmpty()) WireButtonState.Disabled else WireButtonState.Error, | ||
), | ||
optionButton2Properties = WireDialogButtonProperties( | ||
text = "Later", | ||
onClick = { }, | ||
type = WireDialogButtonType.Primary, | ||
state = if (password.text.isEmpty()) WireButtonState.Disabled else WireButtonState.Error, | ||
), | ||
dismissButtonProperties = WireDialogButtonProperties( | ||
text = "Cancel", | ||
onClick = { } | ||
), | ||
title = "title", | ||
text = buildAnnotatedString { | ||
val style = SpanStyle( | ||
color = colorsScheme().onBackground, | ||
fontWeight = MaterialTheme.wireTypography.body01.fontWeight, | ||
fontSize = MaterialTheme.wireTypography.body01.fontSize, | ||
fontFamily = MaterialTheme.wireTypography.body01.fontFamily, | ||
fontStyle = MaterialTheme.wireTypography.body01.fontStyle | ||
) | ||
withStyle(style) { append("text") } | ||
}, | ||
buttonsHorizontalAlignment = false | ||
) { | ||
WirePasswordTextField( | ||
value = password, | ||
onValueChange = { password = it }, | ||
autofill = true | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun PreviewWireDialogCentered() { | ||
var password by remember { mutableStateOf(TextFieldValue("")) } | ||
WireTheme { | ||
Box( | ||
contentAlignment = Alignment.Center, | ||
modifier = Modifier.fillMaxWidth() | ||
) { | ||
WireDialogContent( | ||
optionButton1Properties = WireDialogButtonProperties( | ||
text = "OK", | ||
onClick = { }, | ||
type = WireDialogButtonType.Primary, | ||
state = if (password.text.isEmpty()) WireButtonState.Disabled else WireButtonState.Error, | ||
), | ||
dismissButtonProperties = WireDialogButtonProperties( | ||
text = "Cancel", | ||
onClick = { } | ||
), | ||
centerContent = true, | ||
title = "title", | ||
text = buildAnnotatedString { | ||
val style = SpanStyle( | ||
color = colorsScheme().onBackground, | ||
fontWeight = MaterialTheme.wireTypography.body01.fontWeight, | ||
fontSize = MaterialTheme.wireTypography.body01.fontSize, | ||
fontFamily = MaterialTheme.wireTypography.body01.fontFamily, | ||
fontStyle = MaterialTheme.wireTypography.body01.fontStyle | ||
) | ||
withStyle(style) { append("text\nsecond line\nthirdLine\nfourth line\nfifth line\nsixth line\nseventh line") } | ||
}, | ||
) { | ||
WirePasswordTextField( | ||
value = password, | ||
onValueChange = { password = it }, | ||
autofill = false | ||
) | ||
} | ||
} | ||
} | ||
} |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are moving components progressively, this file I created it to maintain the
WireDialog
preview (that depend on components we still don't move toui-commons
)