Fix: App Refactor when Control tokens updates (#423)
* Add a themeID to force recomposition across controls * Reformating * Change update method for ThemeID and comment for themeID
This commit is contained in:
Родитель
a4d3c2fdbf
Коммит
ce4fa7e5df
|
@ -111,7 +111,7 @@ class V2ButtonsActivity : DemoActivity() {
|
|||
size = ButtonSize.Medium,
|
||||
onClick = {
|
||||
FluentTheme.updateControlTokens(
|
||||
ControlTokens().updateToken(
|
||||
controlTokens.updateToken(
|
||||
ControlTokens.ControlType.AppBar,
|
||||
MyAppBarToken()
|
||||
).updateToken(
|
||||
|
|
|
@ -83,6 +83,8 @@ fun ContextualCommandBar(
|
|||
contextualCommandBarToken: ContextualCommandBarTokens? = null
|
||||
) {
|
||||
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = contextualCommandBarToken
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.ContextualCommandBar] as ContextualCommandBarTokens
|
||||
|
||||
|
|
|
@ -47,6 +47,8 @@ fun AnnouncementCard(
|
|||
@DrawableRes previewImageDrawable: Int? = null,
|
||||
announcementCardTokens: AnnouncementCardTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = announcementCardTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.AnnouncementCard] as AnnouncementCardTokens
|
||||
val announcementCardInfo = AnnouncementCardInfo()
|
||||
|
|
|
@ -28,6 +28,8 @@ fun BasicCard(
|
|||
basicCardTokens: BasicCardTokens? = null,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = basicCardTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.BasicCard] as BasicCardTokens
|
||||
val basicCardInfo = BasicCardInfo(CardType.Elevated)
|
||||
|
|
|
@ -58,6 +58,8 @@ fun Button(
|
|||
contentDescription: String? = null,
|
||||
buttonTokens: ButtonTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = buttonTokens ?: FluentTheme.controlTokens.tokens[ControlType.Button] as ButtonTokens
|
||||
val buttonInfo = ButtonInfo(style, size)
|
||||
val clickAndSemanticsModifier = Modifier.clickable(
|
||||
|
|
|
@ -53,6 +53,8 @@ fun CheckBox(
|
|||
checkBoxToken: CheckBoxTokens? = null
|
||||
) {
|
||||
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = checkBoxToken
|
||||
?: FluentTheme.controlTokens.tokens[ControlType.CheckBox] as CheckBoxTokens
|
||||
val checkBoxInfo = CheckBoxInfo(checked)
|
||||
|
|
|
@ -38,6 +38,8 @@ fun Citation(
|
|||
modifier: Modifier = Modifier,
|
||||
citationTokens: CitationTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val tokens = citationTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.Citation] as CitationTokens
|
||||
val citationInfo = CitationInfo()
|
||||
|
|
|
@ -59,6 +59,8 @@ fun FileCard(
|
|||
actionOverflowIcon: FluentIcon? = null,
|
||||
fileCardTokens: FileCardTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = fileCardTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.FileCard] as FileCardTokens
|
||||
val isPreviewAvailable = !(previewImageDrawable == null && previewImageVector == null)
|
||||
|
|
|
@ -57,6 +57,8 @@ fun FloatingActionButton(
|
|||
if (icon == null && (text == null || text == ""))
|
||||
return
|
||||
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = fabTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlType.FloatingActionButton] as FABTokens
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ fun Label(
|
|||
modifier: Modifier = Modifier,
|
||||
labelTokens: LabelTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val tokens = labelTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.Label] as LabelTokens
|
||||
val labelInfo = LabelInfo(textStyle, colorStyle)
|
||||
|
|
|
@ -45,6 +45,8 @@ fun RadioButton(
|
|||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||
radioButtonToken: RadioButtonTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = radioButtonToken
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.RadioButton] as RadioButtonTokens
|
||||
val radioButtonInfo = RadioButtonInfo(selected)
|
||||
|
|
|
@ -95,6 +95,8 @@ fun TextField(
|
|||
visualTransformation: VisualTransformation = VisualTransformation.None,
|
||||
textFieldTokens: TextFieldTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = textFieldTokens
|
||||
?: (FluentTheme.controlTokens.tokens[ControlTokens.ControlType.TextField] as TextFieldTokens)
|
||||
|
||||
|
|
|
@ -61,6 +61,8 @@ fun ToggleSwitch(
|
|||
switchTokens: ToggleSwitchTokens? = null
|
||||
) {
|
||||
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = switchTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlType.ToggleSwitch] as ToggleSwitchTokens
|
||||
val toggleSwitchInfo = ToggleSwitchInfo(checkedState)
|
||||
|
|
|
@ -13,6 +13,7 @@ enum class ThemeMode {
|
|||
}
|
||||
|
||||
internal val LocalThemeMode = compositionLocalOf { ThemeMode.Auto }
|
||||
internal val LocalThemeID = compositionLocalOf { 1 }
|
||||
|
||||
/**
|
||||
* FluentTheme function is a entry point for UI created using Fluent Control. Provide your UI Logic
|
||||
|
@ -44,11 +45,13 @@ fun FluentTheme(
|
|||
val appAliasTokens by FluentTheme.observeAliasToken(initial = AliasTokens())
|
||||
val appControlTokens by FluentTheme.observeControlToken(initial = ControlTokens())
|
||||
val appThemeMode by FluentTheme.observeThemeMode(initial = ThemeMode.Auto)
|
||||
val appThemeID by FluentTheme.observeThemeID(initial = 1)
|
||||
|
||||
CompositionLocalProvider(
|
||||
LocalAliasTokens provides (aliasTokens ?: appAliasTokens),
|
||||
LocalControlTokens provides (controlTokens ?: appControlTokens),
|
||||
LocalThemeMode provides (themeMode ?: appThemeMode)
|
||||
LocalThemeMode provides (themeMode ?: appThemeMode),
|
||||
LocalThemeID provides appThemeID
|
||||
) {
|
||||
content()
|
||||
}
|
||||
|
@ -82,15 +85,23 @@ object FluentTheme : ViewModel() {
|
|||
@ReadOnlyComposable
|
||||
get() = LocalThemeMode.current
|
||||
|
||||
|
||||
val themeID: Int
|
||||
@Composable
|
||||
@ReadOnlyComposable
|
||||
get() = LocalThemeID.current
|
||||
|
||||
private var aliasTokens_: MutableLiveData<IAliasTokens> = MutableLiveData(AliasTokens())
|
||||
private var controlTokens_: MutableLiveData<IControlTokens> = MutableLiveData(ControlTokens())
|
||||
private var themeMode_: MutableLiveData<ThemeMode> = MutableLiveData(ThemeMode.Auto)
|
||||
private var themeID_: MutableLiveData<Int> = MutableLiveData(1)
|
||||
|
||||
/**
|
||||
* Update aliasTokens across all FluentTheme scope where explicit values is not provided to it.
|
||||
*/
|
||||
fun updateAliasTokens(overrideAliasTokens: IAliasTokens) {
|
||||
aliasTokens_.value = overrideAliasTokens
|
||||
updateThemeID()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,6 +109,7 @@ object FluentTheme : ViewModel() {
|
|||
*/
|
||||
fun updateControlTokens(overrideControlTokens: IControlTokens) {
|
||||
controlTokens_.value = overrideControlTokens
|
||||
updateThemeID()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,6 +117,14 @@ object FluentTheme : ViewModel() {
|
|||
*/
|
||||
fun updateThemeMode(overrideThemeMode: ThemeMode) {
|
||||
themeMode_.value = overrideThemeMode
|
||||
updateThemeID()
|
||||
}
|
||||
|
||||
/*
|
||||
* Update ThemeID for a new combination of AliasTokens, ControlTokens and ThemeMode.
|
||||
*/
|
||||
private fun updateThemeID() {
|
||||
themeID_.value = themeID_.value?.plus(1)
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
@ -112,11 +132,6 @@ object FluentTheme : ViewModel() {
|
|||
return this.aliasTokens_.observeAsState(initial)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun observeAliasToken(): State<IAliasTokens?> {
|
||||
return this.aliasTokens_.observeAsState()
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun observeControlToken(initial: IControlTokens): State<IControlTokens> {
|
||||
return this.controlTokens_.observeAsState(initial)
|
||||
|
@ -126,4 +141,9 @@ object FluentTheme : ViewModel() {
|
|||
internal fun observeThemeMode(initial: ThemeMode): State<ThemeMode> {
|
||||
return this.themeMode_.observeAsState(initial = initial)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun observeThemeID(initial: Int): State<Int> {
|
||||
return this.themeID_.observeAsState(initial = initial)
|
||||
}
|
||||
}
|
|
@ -225,6 +225,8 @@ fun BottomSheet(
|
|||
bottomSheetTokens: BottomSheetTokens? = null,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val tokens = bottomSheetTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.BottomSheet] as BottomSheetTokens
|
||||
|
||||
|
|
|
@ -808,6 +808,8 @@ fun Drawer(
|
|||
drawerContent: @Composable () -> Unit
|
||||
) {
|
||||
if (drawerState.enable) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val tokens = drawerTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.Drawer] as DrawerTokens
|
||||
|
||||
|
|
|
@ -299,6 +299,8 @@ class ListContentBuilder {
|
|||
}
|
||||
|
||||
items(itemDataList) { item ->
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = listItemTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.ListItem] as ListItemTokens
|
||||
ListItem.Item(
|
||||
|
|
|
@ -17,6 +17,8 @@ fun Divider(
|
|||
height: Dp = 1.dp,
|
||||
dividerToken: DividerTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token =
|
||||
dividerToken
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.Divider] as DividerTokens
|
||||
|
|
|
@ -249,6 +249,8 @@ object ListItem {
|
|||
} else {
|
||||
ThreeLine
|
||||
}
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = listItemTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlType.ListItem] as ListItemTokens
|
||||
val listItemInfo = ListItemInfo(
|
||||
|
@ -458,7 +460,8 @@ object ListItem {
|
|||
listItemTokens: ListItemTokens? = null,
|
||||
content: (@Composable () -> Unit)? = null
|
||||
) {
|
||||
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = listItemTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlType.ListItem] as ListItemTokens
|
||||
val listItemInfo = ListItemInfo(
|
||||
|
@ -623,6 +626,8 @@ object ListItem {
|
|||
trailingAccessoryView: (@Composable () -> Unit)? = null,
|
||||
listItemTokens: ListItemTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = listItemTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlType.ListItem] as ListItemTokens
|
||||
val listItemInfo = ListItemInfo(
|
||||
|
@ -751,6 +756,8 @@ object ListItem {
|
|||
trailingAccessoryView: (@Composable () -> Unit)? = null,
|
||||
listItemTokens: ListItemTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = listItemTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlType.ListItem] as ListItemTokens
|
||||
val listItemInfo = ListItemInfo(
|
||||
|
|
|
@ -44,6 +44,8 @@ fun TabItem(
|
|||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||
tabItemTokens: TabItemTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token =
|
||||
tabItemTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.TabItem] as TabItemTokens
|
||||
|
|
|
@ -37,6 +37,8 @@ fun Dialog(
|
|||
dialogTokens: DialogTokens? = null,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = dialogTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.Dialog] as DialogTokens
|
||||
val dialogInfo = DialogInfo()
|
||||
|
|
|
@ -66,6 +66,8 @@ fun Menu(
|
|||
openedStates.targetState = opened
|
||||
|
||||
if (openedStates.currentState || openedStates.targetState) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token =
|
||||
menuTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.Menu] as MenuTokens
|
||||
|
|
|
@ -40,6 +40,8 @@ fun Badge(
|
|||
badgeType: BadgeType = BadgeType.List,
|
||||
badgeTokens: BadgeTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = badgeTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.Badge] as BadgeTokens
|
||||
val badgeInfo = BadgeInfo(badgeType)
|
||||
|
|
|
@ -83,6 +83,8 @@ fun CardNudge(
|
|||
outlineMode: Boolean = false,
|
||||
cardNudgeTokens: CardNudgeTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = cardNudgeTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.CardNudge] as CardNudgeTokens
|
||||
|
||||
|
|
|
@ -116,6 +116,8 @@ fun Snackbar(
|
|||
) {
|
||||
val metadata: SnackbarMetadata = snackbarState.currentSnackbar ?: return
|
||||
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = snackbarTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.Snackbar] as SnackBarTokens
|
||||
|
||||
|
|
|
@ -62,6 +62,8 @@ fun Avatar(
|
|||
avatarToken: AvatarTokens? = null
|
||||
) {
|
||||
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = avatarToken
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.Avatar] as AvatarTokens
|
||||
|
||||
|
@ -223,6 +225,8 @@ fun Avatar(
|
|||
avatarToken: AvatarTokens? = null,
|
||||
) {
|
||||
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = avatarToken
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.Avatar] as AvatarTokens
|
||||
|
||||
|
@ -314,6 +318,8 @@ fun Avatar(
|
|||
enableActivityRings: Boolean = false,
|
||||
avatarToken: AvatarTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = avatarToken
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.Avatar] as AvatarTokens
|
||||
|
||||
|
|
|
@ -58,6 +58,8 @@ fun AvatarCarousel(
|
|||
avatarTokens: AvatarTokens? = null,
|
||||
avatarCarouselTokens: AvatarCarouselTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = avatarCarouselTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.AvatarCarousel] as AvatarCarouselTokens
|
||||
val avatarCarouselInfo = AvatarCarouselInfo(size)
|
||||
|
|
|
@ -40,6 +40,8 @@ fun AvatarGroup(
|
|||
avatarToken: AvatarTokens? = null,
|
||||
avatarGroupToken: AvatarGroupTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = avatarGroupToken
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.AvatarGroup] as AvatarGroupTokens
|
||||
|
||||
|
|
|
@ -2,11 +2,13 @@ package com.microsoft.fluentui.tokenized.persona
|
|||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.microsoft.fluentui.theme.token.controlTokens.*
|
||||
import com.microsoft.fluentui.theme.token.controlTokens.AvatarTokens
|
||||
import com.microsoft.fluentui.theme.token.controlTokens.BorderInset
|
||||
import com.microsoft.fluentui.theme.token.controlTokens.BorderInset.None
|
||||
import com.microsoft.fluentui.theme.token.controlTokens.BorderType
|
||||
import com.microsoft.fluentui.theme.token.controlTokens.BorderType.NoBorder
|
||||
import com.microsoft.fluentui.theme.token.controlTokens.ListItemTokens
|
||||
import com.microsoft.fluentui.tokenized.listitem.ListItem
|
||||
import com.microsoft.fluentui.tokenized.listitem.TextIcons
|
||||
|
||||
/**
|
||||
* A customized list item. Can be a Single or multiline Avatar item. Size of the persona is based on the texts provided
|
||||
|
|
|
@ -55,6 +55,8 @@ fun PersonaChip(
|
|||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||
personaChipTokens: PersonaChipTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = personaChipTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.PersonaChip] as PersonaChipTokens
|
||||
val personaChipInfo = PersonaChipInfo(
|
||||
|
|
|
@ -48,14 +48,16 @@ fun PersonaList(
|
|||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val lazyListState = rememberLazyListState()
|
||||
LazyColumn(state = lazyListState, modifier = modifier.draggable(
|
||||
orientation = Orientation.Vertical,
|
||||
state = rememberDraggableState { delta ->
|
||||
scope.launch {
|
||||
lazyListState.scrollBy(-delta)
|
||||
}
|
||||
},
|
||||
)) {
|
||||
LazyColumn(
|
||||
state = lazyListState, modifier = modifier.draggable(
|
||||
orientation = Orientation.Vertical,
|
||||
state = rememberDraggableState { delta ->
|
||||
scope.launch {
|
||||
lazyListState.scrollBy(-delta)
|
||||
}
|
||||
},
|
||||
)
|
||||
) {
|
||||
items(personas) { item ->
|
||||
ListItem.Item(
|
||||
text = item.title,
|
||||
|
|
|
@ -54,6 +54,8 @@ fun SearchBarPersonaChip(
|
|||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||
searchbarPersonaChipTokens: SearchBarPersonaChipTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = searchbarPersonaChipTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.SearchBarPersonaChip] as SearchBarPersonaChipTokens
|
||||
val searchBarPersonaChipInfo = SearchBarPersonaChipInfo(
|
||||
|
|
|
@ -36,6 +36,8 @@ fun CircularProgressIndicator(
|
|||
style: FluentStyle = FluentStyle.Neutral,
|
||||
circularProgressIndicatorTokens: CircularProgressIndicatorTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val tokens = circularProgressIndicatorTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.CircularProgressIndicator] as CircularProgressIndicatorTokens
|
||||
val circularProgressIndicatorInfo = CircularProgressIndicatorInfo(
|
||||
|
@ -98,6 +100,8 @@ fun CircularProgressIndicator(
|
|||
style: FluentStyle = FluentStyle.Neutral,
|
||||
circularProgressIndicatorTokens: CircularProgressIndicatorTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val tokens = circularProgressIndicatorTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.CircularProgressIndicator] as CircularProgressIndicatorTokens
|
||||
val circularProgressIndicatorInfo = CircularProgressIndicatorInfo(
|
||||
|
@ -129,9 +133,9 @@ fun CircularProgressIndicator(
|
|||
)
|
||||
val indicatorSizeInPx = dpToPx(circularProgressIndicatorSize)
|
||||
Canvas(
|
||||
modifier = modifier
|
||||
.requiredSize(circularProgressIndicatorSize)
|
||||
.progressSemantics()
|
||||
modifier = modifier
|
||||
.requiredSize(circularProgressIndicatorSize)
|
||||
.progressSemantics()
|
||||
) {
|
||||
drawArc(
|
||||
circularProgressIndicatorColor,
|
||||
|
@ -142,6 +146,6 @@ fun CircularProgressIndicator(
|
|||
indicatorSizeInPx, indicatorSizeInPx
|
||||
),
|
||||
style = Stroke(dpToPx(circularProgressIndicatorStrokeWidth), cap = StrokeCap.Round)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ fun LinearProgressIndicator(
|
|||
linearProgressIndicatorHeight: LinearProgressIndicatorHeight = LinearProgressIndicatorHeight.XXXSmall,
|
||||
linearProgressIndicatorTokens: LinearProgressIndicatorTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val tokens = linearProgressIndicatorTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.LinearProgressIndicator] as LinearProgressIndicatorTokens
|
||||
val linearProgressIndicatorInfo = LinearProgressIndicatorInfo(
|
||||
|
@ -97,6 +99,8 @@ fun LinearProgressIndicator(
|
|||
linearProgressIndicatorHeight: LinearProgressIndicatorHeight = LinearProgressIndicatorHeight.XXXSmall,
|
||||
linearProgressIndicatorTokens: LinearProgressIndicatorTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val tokens = linearProgressIndicatorTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.LinearProgressIndicator] as LinearProgressIndicatorTokens
|
||||
val linearProgressIndicatorInfo = LinearProgressIndicatorInfo(
|
||||
|
|
|
@ -42,6 +42,8 @@ fun ProgressText(
|
|||
modifier: Modifier = Modifier,
|
||||
progressTextTokens: ProgressTextTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val tokens = progressTextTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.ProgressText] as ProgressTextTokens
|
||||
val progressTextInfo = ProgressTextInfo(progress)
|
||||
|
|
|
@ -41,6 +41,8 @@ fun Shimmer(
|
|||
shape: ShimmerShape = ShimmerShape.Box,
|
||||
shimmerTokens: ShimmerTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val tokens = shimmerTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.Shimmer] as ShimmerTokens
|
||||
val configuration = LocalConfiguration.current
|
||||
|
|
|
@ -9,7 +9,10 @@ import androidx.compose.ui.unit.dp
|
|||
import com.microsoft.fluentui.theme.FluentTheme
|
||||
import com.microsoft.fluentui.theme.token.ControlTokens
|
||||
import com.microsoft.fluentui.theme.token.FluentStyle
|
||||
import com.microsoft.fluentui.theme.token.controlTokens.*
|
||||
import com.microsoft.fluentui.theme.token.controlTokens.TabBarInfo
|
||||
import com.microsoft.fluentui.theme.token.controlTokens.TabBarTokens
|
||||
import com.microsoft.fluentui.theme.token.controlTokens.TabItemTokens
|
||||
import com.microsoft.fluentui.theme.token.controlTokens.TabTextAlignment
|
||||
import com.microsoft.fluentui.tokenized.tabItem.TabItem
|
||||
|
||||
|
||||
|
@ -42,6 +45,8 @@ fun TabBar(
|
|||
tabItemTokens: TabItemTokens? = null,
|
||||
tabBarTokens: TabBarTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = tabBarTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.TabBar] as TabBarTokens
|
||||
|
||||
|
|
|
@ -75,6 +75,8 @@ fun PillButton(
|
|||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||
pillButtonTokens: PillButtonTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = pillButtonTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.PillButton] as PillButtonTokens
|
||||
val pillButtonInfo = PillButtonInfo(
|
||||
|
@ -245,6 +247,8 @@ fun PillBar(
|
|||
if (metadataList.size == 0)
|
||||
return
|
||||
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = pillBarTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.PillBar] as PillBarTokens
|
||||
|
||||
|
|
|
@ -47,6 +47,8 @@ fun PillSwitch(
|
|||
if (metadataList.size == 0)
|
||||
return
|
||||
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = pillSwitchTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.PillSwitch] as PillSwitchTokens
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ fun PillTabs(
|
|||
if (metadataList.size == 0)
|
||||
return
|
||||
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token =
|
||||
tabsTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.PillTabs] as PillTabsTokens
|
||||
|
|
|
@ -80,6 +80,8 @@ fun AppBar(
|
|||
accessoryDelta: Float = 1.0F,
|
||||
appBarTokens: AppBarTokens? = null
|
||||
) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = appBarTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.AppBar] as AppBarTokens
|
||||
|
||||
|
|
|
@ -93,7 +93,8 @@ fun SearchBar(
|
|||
rightAccessoryIcon: FluentIcon? = null,
|
||||
searchBarTokens: SearchBarTokens? = null
|
||||
) {
|
||||
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
val token = searchBarTokens
|
||||
?: FluentTheme.controlTokens.tokens[ControlTokens.ControlType.SearchBar] as SearchBarTokens
|
||||
val searchBarInfo = SearchBarInfo(style)
|
||||
|
|
Загрузка…
Ссылка в новой задаче