Skip to content

Commit

Permalink
Moving DialogProperties to API. (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
NamanPandey authored Jul 10, 2023
1 parent adb7d2d commit 5292b57
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import android.widget.Toast
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogProperties
import com.microsoft.fluentui.theme.FluentTheme
import com.microsoft.fluentui.theme.token.FluentAliasTokens
import com.microsoft.fluentui.theme.token.controlTokens.ButtonStyle
Expand Down Expand Up @@ -41,6 +43,7 @@ class V2DialogActivity : DemoActivity() {
}
}

@OptIn(ExperimentalComposeUiApi::class)
@Composable
private fun CreateDialogActivityUI(context: Context) {
var showDialog by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -90,6 +93,7 @@ class V2DialogActivity : DemoActivity() {
onClick = { showDialog = !showDialog }
)
}
var count by remember { mutableStateOf(1) }
if (showDialog) {
Dialog(
onDismiss = {
Expand All @@ -100,27 +104,26 @@ class V2DialogActivity : DemoActivity() {
Toast.LENGTH_SHORT
).show()
},
dismissOnClickedOutside = dismissOnClickOutside,
dismissOnBackPress = dismissOnBackPress
dialogProperties = DialogProperties(
dismissOnClickOutside = dismissOnClickOutside,
dismissOnBackPress = dismissOnBackPress,
usePlatformDefaultWidth = false
)
) {
Column(Modifier.padding(all = 16.dp)) {
Label(
text = resources.getString(R.string.dialog_description),
textStyle = FluentAliasTokens.TypographyTokens.Body1
)
Spacer(modifier = Modifier.height(16.dp))
for (i in 0..count) {
Label(
text = resources.getString(R.string.dialog_description),
textStyle = FluentAliasTokens.TypographyTokens.Body1
)
Spacer(modifier = Modifier.height(16.dp))
}
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) {
Button(
style = ButtonStyle.TextButton,
text = resources.getString(R.string.cancel),
text = "Add Item",
onClick = {
showDialog = false
Toast.makeText(
context,
resources.getString(R.string.cancel),
Toast.LENGTH_SHORT
)
.show()
count++
})
Spacer(modifier = Modifier.width(8.dp))
Button(
Expand Down
4 changes: 2 additions & 2 deletions config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ project.ext.fluentui_ccb_versionid = '0.1.12'
project.ext.fluentui_others_versionid = '0.1.6'
project.ext.fluentui_transients_versionid = '0.0.32'
project.ext.fluentui_topappbars_versionid = '0.1.7'
project.ext.fluentui_menus_versionid = '0.1.1'
project.ext.fluentui_menus_versionid = '0.1.2'
project.ext.fluentui_peoplepicker_versionid = '0.0.27'
project.ext.fluentui_persona_versionid = '0.1.12'
project.ext.fluentui_progress_versionid = '0.1.6'
Expand All @@ -38,7 +38,7 @@ project.ext.fluentui_ccb_version_code = 36
project.ext.fluentui_others_version_code = 29
project.ext.fluentui_transients_version_code = 32
project.ext.fluentui_topappbars_version_code = 33
project.ext.fluentui_menus_version_code = 29
project.ext.fluentui_menus_version_code = 30
project.ext.fluentui_peoplepicker_version_code = 27
project.ext.fluentui_persona_version_code = 37
project.ext.fluentui_progress_version_code = 31
Expand Down
3 changes: 2 additions & 1 deletion dogfood-release-notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Fluent V2:
1) [Breaking Change] ListItem texticons slot changed to composable slot. Suffix of parameter changed from "View" to "Content"
2) [Breaking Change] CardNugde leftSwipe and rightSwipe lambda functions will have a float parameter to depicting the fraction value for the swipe.
3) [Breaking Change] Drawer API will not have expandable boolean parameter.
4) Fix accessibility issue in ListItem SectionHeader
4) [Breaking Change] Updated Dialog API to accept DialogProperties instead of individual params.
5) Fix accessibility issue in ListItem SectionHeader


Demo App:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.compose.ui.window.SecureFlagPolicy
import com.microsoft.fluentui.theme.FluentTheme
import com.microsoft.fluentui.theme.token.ControlTokens
import com.microsoft.fluentui.theme.token.controlTokens.DialogInfo
Expand All @@ -28,11 +30,16 @@ const val TEST_TAG = "Dialog"
* @param dialogTokens Optional tokens for customizing dialog's visual appearance
* @param content content to be displayed inside the dialog
*/
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun Dialog(
onDismiss: () -> Unit,
dismissOnBackPress: Boolean = false,
dismissOnClickedOutside: Boolean = false,
dialogProperties: DialogProperties = DialogProperties(
dismissOnBackPress = false,
dismissOnClickOutside = false,
securePolicy = SecureFlagPolicy.Inherit,
usePlatformDefaultWidth = true
),
modifier: Modifier = Modifier,
dialogTokens: DialogTokens? = null,
content: @Composable () -> Unit
Expand All @@ -50,10 +57,7 @@ fun Dialog(
val shape = RoundedCornerShape(cornerRadius)
Dialog(
onDismissRequest = onDismiss,
DialogProperties(
dismissOnBackPress = dismissOnBackPress,
dismissOnClickOutside = dismissOnClickedOutside
)
properties = dialogProperties
) {
Box(
modifier = modifier
Expand Down

0 comments on commit 5292b57

Please sign in to comment.