Skip to content
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

[fluent] refactor: Migrate to new FontIcon #86

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import com.konyaco.fluent.FluentTheme
import com.konyaco.fluent.LocalContentAlpha
import com.konyaco.fluent.LocalContentColor
import com.konyaco.fluent.LocalTextStyle
import com.konyaco.fluent.icons.Icons
import com.konyaco.fluent.icons.filled.ChevronRight
import com.konyaco.fluent.icons.filled.MoreHorizontal
import com.konyaco.fluent.layout.overflow.OverflowActionScope
import com.konyaco.fluent.layout.overflow.OverflowFlyoutContainer
import com.konyaco.fluent.layout.overflow.OverflowPosition
Expand Down Expand Up @@ -140,10 +136,9 @@ object BreadcrumbBarDefaults {
enabled = enabled
) {
FontIcon(
glyph = '\uE712',
vector = Icons.Filled.MoreHorizontal,
type = FontIconPrimitive.More,
contentDescription = null,
iconSize = FontIconDefaults.fontSizeSmall
size = FontIconSize.Small
)
}
}
Expand All @@ -164,10 +159,9 @@ object BreadcrumbBarDefaults {
enabled = enabled
) {
FontIcon(
glyph = '\uE712',
vector = Icons.Filled.MoreHorizontal,
type = FontIconPrimitive.More,
contentDescription = null,
iconSize = FontIconDefaults.fontSizeStandard
size = FontIconSize.Standard
)
}
}
Expand All @@ -193,7 +187,7 @@ fun BreadcrumbBarItem(
colorScheme = colorScheme,
chevronColors = chevronColors,
textStyle = FluentTheme.typography.body,
chevronSize = FontIconDefaults.fontSizeSmall,
chevronSize = FontIconSize.Small,
modifier = modifier,
chevronVisible = chevronVisible,
enabled = enabled,
Expand Down Expand Up @@ -221,7 +215,7 @@ fun LargeBreadcrumbBarItem(
colorScheme = colorScheme,
chevronColors = chevronColors,
textStyle = FluentTheme.typography.title,
chevronSize = FontIconDefaults.fontSizeStandard,
chevronSize = FontIconSize.Standard,
modifier = modifier,
chevronVisible = chevronVisible,
enabled = enabled,
Expand Down Expand Up @@ -254,7 +248,7 @@ private fun BasicBreadcrumbBarItem(
colorScheme: VisualStateScheme<Color>,
chevronColors: VisualStateScheme<Color>,
textStyle: TextStyle,
chevronSize: TextUnit,
chevronSize: FontIconSize,
modifier: Modifier = Modifier,
chevronVisible: Boolean = true,
enabled: Boolean = true,
Expand Down Expand Up @@ -294,11 +288,10 @@ private fun BasicBreadcrumbBarItem(
LocalTextStyle provides LocalTextStyle.current.copy(chevronColor)
) {
FontIcon(
glyph = '\uE974',
vector = Icons.Filled.ChevronRight,
type = FontIconPrimitive.ChevronRight,
contentDescription = null,
modifier = Modifier.padding(horizontal = 4.dp),
iconSize = chevronSize
size = chevronSize
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ import com.konyaco.fluent.animation.FluentDuration
import com.konyaco.fluent.animation.FluentEasing
import com.konyaco.fluent.background.BackgroundSizing
import com.konyaco.fluent.background.Layer
import com.konyaco.fluent.icons.Icons
import com.konyaco.fluent.icons.regular.ChevronDown
import com.konyaco.fluent.scheme.PentaVisualScheme
import com.konyaco.fluent.scheme.VisualState
import com.konyaco.fluent.scheme.VisualStateScheme
Expand Down Expand Up @@ -716,10 +714,11 @@ private fun AnimatedDropDownIcon(interaction: MutableInteractionSource) {
targetValue = if (isPressed) 2.dp else 0.dp,
animationSpec = tween(FluentDuration.ShortDuration, easing = FluentEasing.FastInvokeEasing)
)
Icon(
imageVector = Icons.Default.ChevronDown,
FontIcon(
type = FontIconPrimitive.ChevronDown,
size = FontIconSize.Small,
contentDescription = null,
modifier = Modifier.graphicsLayer { translationY = animatedOffset.value.toPx() }.size(12.dp)
modifier = Modifier.graphicsLayer { translationY = animatedOffset.value.toPx() }
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import com.konyaco.fluent.ExperimentalFluentApi
import com.konyaco.fluent.icons.Icons
import com.konyaco.fluent.icons.regular.CalendarLtr

/**
* A calendar view lets a user view and interact with a calendar that they can navigate by month, year, or decade. A user can select a single date or a range of dates. It doesn't have a picker surface and the calendar is always visible.
Expand Down Expand Up @@ -50,7 +48,7 @@ fun CalendarDatePicker(
"${day.year}/${day.monthValue + 1}/${day.day}"
} ?: "Pick a date"
)
Icon(Icons.Default.CalendarLtr, null)
FontIcon(type = FontIconPrimitive.Calendar, contentDescription = null)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ import com.konyaco.fluent.animation.FluentEasing
import com.konyaco.fluent.background.BackgroundSizing
import com.konyaco.fluent.background.Layer
import com.konyaco.fluent.component.CalendarDatePickerState.ChooseType
import com.konyaco.fluent.icons.Icons
import com.konyaco.fluent.icons.filled.CaretDown
import com.konyaco.fluent.icons.filled.CaretUp
import com.konyaco.fluent.scheme.PentaVisualScheme
import com.konyaco.fluent.scheme.collectVisualState
import kotlinx.datetime.Clock
Expand Down Expand Up @@ -375,16 +372,17 @@ private fun PaginationButton(
) {
Box(Modifier.requiredSize(40.dp), Alignment.Center) {
SubtleButton(modifier = Modifier.height(30.dp), onClick = onClick, iconOnly = true) {
if (up) Icon(
modifier = Modifier.size(12.dp),
imageVector = Icons.Filled.CaretUp,
contentDescription = "Up"
)
else Icon(
modifier = Modifier.size(12.dp),
imageVector = Icons.Filled.CaretDown,
contentDescription = "Down"
)
if (up) {
FontIconSolid8(
type = FontIconPrimitive.CaretUp,
contentDescription = "Up",
)
} else {
FontIconSolid8(
type = FontIconPrimitive.CaretDown,
contentDescription = "Down",
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import com.konyaco.fluent.animation.FluentDuration
import com.konyaco.fluent.animation.FluentEasing
import com.konyaco.fluent.background.BackgroundSizing
import com.konyaco.fluent.background.Layer
import com.konyaco.fluent.icons.Icons
import com.konyaco.fluent.icons.regular.Checkmark
import com.konyaco.fluent.scheme.PentaVisualScheme
import com.konyaco.fluent.scheme.VisualStateScheme
import com.konyaco.fluent.scheme.collectVisualState
Expand Down Expand Up @@ -84,10 +82,10 @@ fun CheckBox(
)
) {
Box(Modifier.fillMaxSize(), Alignment.Center) {
Icon(
modifier = Modifier.size(16.dp),
imageVector = Icons.Default.Checkmark,
contentDescription = null
FontIcon(
type = FontIconPrimitive.Accept,
contentDescription = null,
size = FontIconSize.Small
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ import com.konyaco.fluent.FluentTheme
import com.konyaco.fluent.LocalContentColor
import com.konyaco.fluent.background.BackgroundSizing
import com.konyaco.fluent.background.Layer
import com.konyaco.fluent.icons.Icons
import com.konyaco.fluent.icons.regular.ChevronDown
import com.konyaco.fluent.icons.regular.ChevronUp
import kotlinx.coroutines.flow.collectLatest
import kotlin.math.PI
import kotlin.math.atan2
Expand Down Expand Up @@ -187,10 +184,15 @@ fun ColorPicker(
verticalAlignment = Alignment.CenterVertically
) {
Text(text = text)
Icon(
imageVector = if (!expanded) Icons.Default.ChevronDown else Icons.Default.ChevronUp,
FontIcon(
type = if (!expanded) {
FontIconPrimitive.ChevronDown
} else {
FontIconPrimitive.ChevronUp

},
contentDescription = text,
modifier = Modifier.size(12.dp)
size = FontIconSize.Small
)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import com.konyaco.fluent.animation.FluentDuration
import com.konyaco.fluent.animation.FluentEasing
import com.konyaco.fluent.background.BackgroundSizing
import com.konyaco.fluent.background.Layer
import com.konyaco.fluent.icons.Icons
import com.konyaco.fluent.icons.filled.MoreHorizontal
import com.konyaco.fluent.layout.alignLast
import com.konyaco.fluent.layout.overflow.OverflowActionScope
import com.konyaco.fluent.layout.overflow.OverflowRow
Expand Down Expand Up @@ -229,11 +227,7 @@ internal fun CommandBarMoreButton(isLarge: Boolean, onClick: () -> Unit) {
onClick = onClick,
iconOnly = true,
content = {
FontIcon(
glyph = '\uE712',
vector = Icons.Filled.MoreHorizontal,
contentDescription = null,
)
FontIcon(type = FontIconPrimitive.More, contentDescription = null)
},
modifier = if (isLarge) {
Modifier.sizeIn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import com.konyaco.fluent.animation.FluentDuration
import com.konyaco.fluent.animation.FluentEasing
import com.konyaco.fluent.background.BackgroundSizing
import com.konyaco.fluent.background.Layer
import com.konyaco.fluent.icons.Icons
import com.konyaco.fluent.icons.regular.ChevronDown
import com.konyaco.fluent.scheme.PentaVisualScheme
import com.konyaco.fluent.scheme.VisualStateScheme
import com.konyaco.fluent.scheme.collectVisualState
Expand Down Expand Up @@ -81,8 +79,8 @@ fun Expander(
onClick = { onExpandedChanged(!expanded) },
content = {
val degrees by animateFloatAsState(if (expanded) 180f else 0f)
Icon(
imageVector = Icons.Default.ChevronDown,
FontIcon(
type = FontIconPrimitive.ChevronDown,
contentDescription = null,
modifier = Modifier.graphicsLayer { rotationZ = degrees }
)
Expand Down
Loading