@expo/ui 55.0.2 → 55.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/ui/AnimatedVisibilityView.kt +130 -0
- package/android/src/main/java/expo/modules/ui/BottomSheetView.kt +91 -13
- package/android/src/main/java/expo/modules/ui/CardView.kt +138 -34
- package/android/src/main/java/expo/modules/ui/CheckboxView.kt +98 -0
- package/android/src/main/java/expo/modules/ui/ChipView.kt +267 -142
- package/android/src/main/java/expo/modules/ui/DatePickerView.kt +258 -70
- package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +209 -61
- package/android/src/main/java/expo/modules/ui/ModifierRegistry.kt +44 -1
- package/android/src/main/java/expo/modules/ui/ProgressView.kt +189 -89
- package/android/src/main/java/expo/modules/ui/RadioButtonView.kt +3 -7
- package/android/src/main/java/expo/modules/ui/SegmentedButtonView.kt +115 -0
- package/android/src/main/java/expo/modules/ui/SegmentedControlView.kt +35 -0
- package/android/src/main/java/expo/modules/ui/SliderView.kt +70 -12
- package/android/src/main/java/expo/modules/ui/SwitchView.kt +53 -161
- package/android/src/main/java/expo/modules/ui/TextInputView.kt +39 -15
- package/android/src/main/java/expo/modules/ui/ToggleButtonView.kt +95 -57
- package/android/src/main/java/expo/modules/ui/button/Button.kt +117 -158
- package/android/src/main/java/expo/modules/ui/button/FloatingActionButton.kt +92 -0
- package/android/src/main/java/expo/modules/ui/button/IconButton.kt +73 -86
- package/android/src/main/java/expo/modules/ui/menu/DropdownMenu.kt +39 -0
- package/android/src/main/java/expo/modules/ui/menu/DropdownMenuItem.kt +70 -0
- package/android/src/main/java/expo/modules/ui/menu/DropdownMenuRecords.kt +18 -0
- package/build/datetime-picker/DateTimePicker.android.d.ts +3 -0
- package/build/datetime-picker/DateTimePicker.android.d.ts.map +1 -0
- package/build/datetime-picker/DateTimePicker.d.ts +3 -0
- package/build/datetime-picker/DateTimePicker.d.ts.map +1 -0
- package/build/datetime-picker/DateTimePicker.web.d.ts +3 -0
- package/build/datetime-picker/DateTimePicker.web.d.ts.map +1 -0
- package/build/datetime-picker/index.d.ts +5 -0
- package/build/datetime-picker/index.d.ts.map +1 -0
- package/build/datetime-picker/types.d.ts +128 -0
- package/build/datetime-picker/types.d.ts.map +1 -0
- package/build/jetpack-compose/AnimatedVisibility/index.d.ts +134 -0
- package/build/jetpack-compose/AnimatedVisibility/index.d.ts.map +1 -0
- package/build/jetpack-compose/AnimatedVisibility/symbols.d.ts +3 -0
- package/build/jetpack-compose/AnimatedVisibility/symbols.d.ts.map +1 -0
- package/build/jetpack-compose/Button/index.d.ts +65 -51
- package/build/jetpack-compose/Button/index.d.ts.map +1 -1
- package/build/jetpack-compose/Card/index.d.ts +72 -14
- package/build/jetpack-compose/Card/index.d.ts.map +1 -1
- package/build/jetpack-compose/Checkbox/index.d.ts +73 -0
- package/build/jetpack-compose/Checkbox/index.d.ts.map +1 -0
- package/build/jetpack-compose/Chip/index.d.ts +247 -27
- package/build/jetpack-compose/Chip/index.d.ts.map +1 -1
- package/build/jetpack-compose/DatePicker/index.d.ts +38 -3
- package/build/jetpack-compose/DatePicker/index.d.ts.map +1 -1
- package/build/jetpack-compose/DropdownMenu/DropdownMenuItem.d.ts +70 -0
- package/build/jetpack-compose/DropdownMenu/DropdownMenuItem.d.ts.map +1 -0
- package/build/jetpack-compose/DropdownMenu/index.d.ts +68 -0
- package/build/jetpack-compose/DropdownMenu/index.d.ts.map +1 -0
- package/build/jetpack-compose/FloatingActionButton/index.d.ts +150 -0
- package/build/jetpack-compose/FloatingActionButton/index.d.ts.map +1 -0
- package/build/jetpack-compose/HorizontalFloatingToolbar/index.d.ts +2 -2
- package/build/jetpack-compose/HorizontalFloatingToolbar/index.d.ts.map +1 -1
- package/build/jetpack-compose/IconButton/index.d.ts +45 -29
- package/build/jetpack-compose/IconButton/index.d.ts.map +1 -1
- package/build/jetpack-compose/ModalBottomSheet/index.d.ts +65 -13
- package/build/jetpack-compose/ModalBottomSheet/index.d.ts.map +1 -1
- package/build/jetpack-compose/MultiChoiceSegmentedButtonRow/index.d.ts +17 -0
- package/build/jetpack-compose/MultiChoiceSegmentedButtonRow/index.d.ts.map +1 -0
- package/build/jetpack-compose/Progress/index.d.ts +78 -35
- package/build/jetpack-compose/Progress/index.d.ts.map +1 -1
- package/build/jetpack-compose/RadioButton/index.d.ts +2 -2
- package/build/jetpack-compose/RadioButton/index.d.ts.map +1 -1
- package/build/jetpack-compose/SegmentedButton/index.d.ts +74 -0
- package/build/jetpack-compose/SegmentedButton/index.d.ts.map +1 -0
- package/build/jetpack-compose/SingleChoiceSegmentedButtonRow/index.d.ts +17 -0
- package/build/jetpack-compose/SingleChoiceSegmentedButtonRow/index.d.ts.map +1 -0
- package/build/jetpack-compose/Slider/index.d.ts +34 -10
- package/build/jetpack-compose/Slider/index.d.ts.map +1 -1
- package/build/jetpack-compose/Switch/index.d.ts +10 -50
- package/build/jetpack-compose/Switch/index.d.ts.map +1 -1
- package/build/jetpack-compose/TextInput/index.d.ts +9 -0
- package/build/jetpack-compose/TextInput/index.d.ts.map +1 -1
- package/build/jetpack-compose/ToggleButton/index.d.ts +60 -32
- package/build/jetpack-compose/ToggleButton/index.d.ts.map +1 -1
- package/build/jetpack-compose/index.d.ts +5 -4
- package/build/jetpack-compose/index.d.ts.map +1 -1
- package/build/jetpack-compose/modifiers/index.d.ts +18 -1
- package/build/jetpack-compose/modifiers/index.d.ts.map +1 -1
- package/build/swift-ui/Link/index.d.ts +36 -0
- package/build/swift-ui/Link/index.d.ts.map +1 -0
- package/build/swift-ui/ProgressView/index.d.ts +1 -5
- package/build/swift-ui/ProgressView/index.d.ts.map +1 -1
- package/build/swift-ui/Stepper/index.d.ts +3 -3
- package/build/swift-ui/Stepper/index.d.ts.map +1 -1
- package/build/swift-ui/Text/index.d.ts +33 -1
- package/build/swift-ui/Text/index.d.ts.map +1 -1
- package/build/swift-ui/index.d.ts +1 -0
- package/build/swift-ui/index.d.ts.map +1 -1
- package/build/swift-ui/modifiers/environment.d.ts +16 -1
- package/build/swift-ui/modifiers/environment.d.ts.map +1 -1
- package/build/swift-ui/modifiers/index.d.ts +24 -7
- package/build/swift-ui/modifiers/index.d.ts.map +1 -1
- package/build/swift-ui/modifiers/shapes/index.d.ts +2 -2
- package/build/swift-ui/modifiers/widgets.d.ts +14 -0
- package/build/swift-ui/modifiers/widgets.d.ts.map +1 -0
- package/build/swift-ui/types.d.ts +7 -0
- package/build/swift-ui/types.d.ts.map +1 -1
- package/expo-module.config.json +1 -1
- package/ios/BottomSheetView.swift +1 -6
- package/ios/ClosedRangeDateRecord.swift +10 -0
- package/ios/ColorPickerView.swift +9 -8
- package/ios/ConfirmationDialog/ConfirmationDialog.swift +4 -6
- package/ios/DatePickerView.swift +7 -5
- package/ios/DisclosureGroupView.swift +5 -7
- package/ios/ExpoUIModule.swift +1 -0
- package/ios/LinkView.swift +29 -0
- package/ios/ListView.swift +6 -14
- package/ios/Modifiers/DefaultScrollAnchorForRoleModifier.swift +32 -0
- package/ios/Modifiers/DefaultScrollAnchorModifier.swift +16 -0
- package/ios/Modifiers/EnvironmentModifier.swift +14 -0
- package/ios/Modifiers/ViewModifierRegistry.swift +12 -0
- package/ios/Modifiers/WidgetModifiers.swift +12 -0
- package/ios/Picker/PickerView.swift +6 -10
- package/ios/Popover/PopoverView.swift +3 -5
- package/ios/ProgressView.swift +0 -5
- package/ios/SectionView.swift +3 -5
- package/ios/SliderView.swift +8 -6
- package/ios/StepperView.swift +12 -16
- package/ios/TextView.swift +37 -1
- package/ios/Toggle/ToggleView.swift +5 -7
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4-sources.jar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4-sources.jar.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4-sources.jar.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4-sources.jar.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4-sources.jar.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.aar.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.aar.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.aar.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.aar.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{55.0.2/expo.modules.ui-55.0.2.module → 55.0.4/expo.modules.ui-55.0.4.module} +22 -22
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.module.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.module.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.module.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.module.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{55.0.2/expo.modules.ui-55.0.2.pom → 55.0.4/expo.modules.ui-55.0.4.pom} +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.pom.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.pom.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.pom.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.4/expo.modules.ui-55.0.4.pom.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml +4 -4
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha512 +1 -1
- package/package.json +9 -2
- package/src/datetime-picker/DateTimePicker.android.tsx +126 -0
- package/src/datetime-picker/DateTimePicker.tsx +94 -0
- package/src/datetime-picker/DateTimePicker.web.tsx +5 -0
- package/src/datetime-picker/index.tsx +11 -0
- package/src/datetime-picker/types.tsx +147 -0
- package/src/jetpack-compose/AnimatedVisibility/index.tsx +206 -0
- package/src/jetpack-compose/AnimatedVisibility/symbols.ts +8 -0
- package/src/jetpack-compose/Button/index.tsx +69 -92
- package/src/jetpack-compose/Card/index.tsx +105 -29
- package/src/jetpack-compose/Checkbox/index.tsx +126 -0
- package/src/jetpack-compose/Chip/index.tsx +391 -51
- package/src/jetpack-compose/DatePicker/index.tsx +112 -7
- package/src/jetpack-compose/DropdownMenu/DropdownMenuItem.tsx +126 -0
- package/src/jetpack-compose/DropdownMenu/index.tsx +107 -0
- package/src/jetpack-compose/FloatingActionButton/index.tsx +207 -0
- package/src/jetpack-compose/HorizontalFloatingToolbar/index.tsx +4 -2
- package/src/jetpack-compose/IconButton/index.tsx +49 -56
- package/src/jetpack-compose/ModalBottomSheet/index.tsx +85 -15
- package/src/jetpack-compose/MultiChoiceSegmentedButtonRow/index.tsx +34 -0
- package/src/jetpack-compose/Progress/index.tsx +120 -62
- package/src/jetpack-compose/RadioButton/index.tsx +8 -9
- package/src/jetpack-compose/SegmentedButton/index.tsx +109 -0
- package/src/jetpack-compose/SingleChoiceSegmentedButtonRow/index.tsx +34 -0
- package/src/jetpack-compose/Slider/index.tsx +76 -29
- package/src/jetpack-compose/Switch/index.tsx +17 -87
- package/src/jetpack-compose/TextInput/index.tsx +10 -0
- package/src/jetpack-compose/ToggleButton/index.tsx +67 -43
- package/src/jetpack-compose/index.ts +5 -4
- package/src/jetpack-compose/modifiers/index.ts +26 -2
- package/src/swift-ui/Link/index.tsx +52 -0
- package/src/swift-ui/ProgressView/index.tsx +1 -3
- package/src/swift-ui/Stepper/index.tsx +7 -7
- package/src/swift-ui/Text/index.tsx +66 -2
- package/src/swift-ui/index.tsx +1 -0
- package/src/swift-ui/modifiers/environment.ts +17 -4
- package/src/swift-ui/modifiers/index.ts +44 -10
- package/src/swift-ui/modifiers/widgets.ts +18 -0
- package/src/swift-ui/types.ts +5 -0
- package/android/src/main/java/expo/modules/ui/FilterChipView.kt +0 -59
- package/android/src/main/java/expo/modules/ui/PickerView.kt +0 -161
- package/android/src/main/java/expo/modules/ui/TextButtonView.kt +0 -33
- package/android/src/main/java/expo/modules/ui/menu/ContextMenu.kt +0 -183
- package/android/src/main/java/expo/modules/ui/menu/ContextMenuRecords.kt +0 -64
- package/build/jetpack-compose/Button/types.d.ts +0 -5
- package/build/jetpack-compose/Button/types.d.ts.map +0 -1
- package/build/jetpack-compose/ContextMenu/Submenu.d.ts +0 -17
- package/build/jetpack-compose/ContextMenu/Submenu.d.ts.map +0 -1
- package/build/jetpack-compose/ContextMenu/index.d.ts +0 -65
- package/build/jetpack-compose/ContextMenu/index.d.ts.map +0 -1
- package/build/jetpack-compose/ContextMenu/utils.d.ts +0 -24
- package/build/jetpack-compose/ContextMenu/utils.d.ts.map +0 -1
- package/build/jetpack-compose/FilterChip/index.d.ts +0 -49
- package/build/jetpack-compose/FilterChip/index.d.ts.map +0 -1
- package/build/jetpack-compose/Picker/index.d.ts +0 -62
- package/build/jetpack-compose/Picker/index.d.ts.map +0 -1
- package/build/jetpack-compose/TextButton/index.d.ts +0 -29
- package/build/jetpack-compose/TextButton/index.d.ts.map +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2-sources.jar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2-sources.jar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2-sources.jar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2-sources.jar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2-sources.jar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.aar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.aar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.aar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.aar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.module.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.module.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.module.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.module.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.pom.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.pom.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.pom.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.pom.sha512 +0 -1
- package/src/jetpack-compose/Button/types.ts +0 -57
- package/src/jetpack-compose/ContextMenu/Submenu.tsx +0 -21
- package/src/jetpack-compose/ContextMenu/index.tsx +0 -149
- package/src/jetpack-compose/ContextMenu/utils.ts +0 -144
- package/src/jetpack-compose/FilterChip/index.tsx +0 -89
- package/src/jetpack-compose/Picker/index.tsx +0 -90
- package/src/jetpack-compose/TextButton/index.tsx +0 -55
|
@@ -1,119 +1,219 @@
|
|
|
1
|
-
@file:OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
|
1
|
+
@file:OptIn(ExperimentalMaterial3ExpressiveApi::class, ExperimentalMaterial3Api::class)
|
|
2
2
|
|
|
3
3
|
package expo.modules.ui
|
|
4
4
|
|
|
5
5
|
import android.graphics.Color
|
|
6
6
|
import androidx.compose.material3.CircularProgressIndicator
|
|
7
7
|
import androidx.compose.material3.CircularWavyProgressIndicator
|
|
8
|
+
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
8
9
|
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
|
|
9
10
|
import androidx.compose.material3.LinearProgressIndicator
|
|
10
11
|
import androidx.compose.material3.LinearWavyProgressIndicator
|
|
11
12
|
import androidx.compose.material3.ProgressIndicatorDefaults
|
|
13
|
+
import androidx.compose.material3.WavyProgressIndicatorDefaults
|
|
12
14
|
import androidx.compose.runtime.Composable
|
|
15
|
+
import androidx.compose.ui.graphics.StrokeCap
|
|
16
|
+
import androidx.compose.ui.unit.dp
|
|
13
17
|
import expo.modules.kotlin.records.Field
|
|
14
18
|
import expo.modules.kotlin.records.Record
|
|
15
|
-
import expo.modules.kotlin.types.Enumerable
|
|
16
19
|
import expo.modules.kotlin.views.ComposeProps
|
|
17
20
|
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
CIRCULAR("circular"),
|
|
21
|
-
LINEAR("linear"),
|
|
22
|
-
CIRCULAR_WAVY("circularWavy"),
|
|
23
|
-
LINEAR_WAVY("linearWavy")
|
|
24
|
-
}
|
|
22
|
+
// region LinearProgressIndicator
|
|
25
23
|
|
|
26
|
-
class
|
|
27
|
-
@Field
|
|
28
|
-
val
|
|
24
|
+
class DrawStopIndicatorConfig : Record {
|
|
25
|
+
@Field val color: Color? = null
|
|
26
|
+
@Field val strokeCap: String? = null
|
|
27
|
+
@Field val stopSize: Float? = null
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
data class
|
|
32
|
-
val variant: ProgressVariant = ProgressVariant.CIRCULAR,
|
|
30
|
+
data class LinearProgressIndicatorProps(
|
|
33
31
|
val progress: Float? = null,
|
|
34
32
|
val color: Color? = null,
|
|
35
|
-
val
|
|
33
|
+
val trackColor: Color? = null,
|
|
34
|
+
val strokeCap: String? = null,
|
|
35
|
+
val gapSize: Float? = null,
|
|
36
|
+
val drawStopIndicator: DrawStopIndicatorConfig? = null,
|
|
36
37
|
val modifiers: ModifierList = emptyList()
|
|
37
38
|
) : ComposeProps
|
|
38
39
|
|
|
39
40
|
@Composable
|
|
40
|
-
fun FunctionalComposableScope.
|
|
41
|
-
val progress = props.progress
|
|
42
|
-
val color = props.color
|
|
43
|
-
val colors = props.elementColors
|
|
41
|
+
fun FunctionalComposableScope.LinearProgressIndicatorContent(props: LinearProgressIndicatorProps) {
|
|
44
42
|
val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
43
|
+
val color = props.color.composeOrNull ?: ProgressIndicatorDefaults.linearColor
|
|
44
|
+
val trackColor = props.trackColor.composeOrNull ?: ProgressIndicatorDefaults.linearTrackColor
|
|
45
|
+
val strokeCap = props.strokeCap.toStrokeCap() ?: ProgressIndicatorDefaults.LinearStrokeCap
|
|
46
|
+
val gapSize = props.gapSize?.dp ?: ProgressIndicatorDefaults.LinearIndicatorTrackGapSize
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
)
|
|
75
|
-
} else {
|
|
76
|
-
CircularProgressIndicator(
|
|
77
|
-
color = composeColor,
|
|
78
|
-
trackColor = colors.trackColor.composeOrNull ?: ProgressIndicatorDefaults.circularIndeterminateTrackColor,
|
|
79
|
-
modifier = modifier
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
ProgressVariant.LINEAR_WAVY -> {
|
|
84
|
-
val composeColor = color.composeOrNull ?: ProgressIndicatorDefaults.linearColor
|
|
85
|
-
val trackColor = colors.trackColor.composeOrNull ?: ProgressIndicatorDefaults.linearTrackColor
|
|
86
|
-
if (progress != null) {
|
|
87
|
-
LinearWavyProgressIndicator(
|
|
88
|
-
progress = { progress },
|
|
89
|
-
color = composeColor,
|
|
90
|
-
trackColor = trackColor,
|
|
91
|
-
modifier = modifier
|
|
92
|
-
)
|
|
93
|
-
} else {
|
|
94
|
-
LinearWavyProgressIndicator(
|
|
95
|
-
color = composeColor,
|
|
96
|
-
trackColor = trackColor,
|
|
97
|
-
modifier = modifier
|
|
98
|
-
)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
ProgressVariant.CIRCULAR_WAVY -> {
|
|
102
|
-
val composeColor = color.composeOrNull ?: ProgressIndicatorDefaults.circularColor
|
|
103
|
-
if (progress != null) {
|
|
104
|
-
CircularWavyProgressIndicator(
|
|
105
|
-
progress = { progress },
|
|
106
|
-
color = composeColor,
|
|
107
|
-
trackColor = colors.trackColor.composeOrNull ?: ProgressIndicatorDefaults.circularDeterminateTrackColor,
|
|
108
|
-
modifier = modifier
|
|
109
|
-
)
|
|
110
|
-
} else {
|
|
111
|
-
CircularWavyProgressIndicator(
|
|
112
|
-
color = composeColor,
|
|
113
|
-
trackColor = colors.trackColor.composeOrNull ?: ProgressIndicatorDefaults.circularDeterminateTrackColor,
|
|
114
|
-
modifier = modifier
|
|
115
|
-
)
|
|
116
|
-
}
|
|
48
|
+
if (props.progress != null) {
|
|
49
|
+
val stopIndicatorConfig = props.drawStopIndicator
|
|
50
|
+
if (stopIndicatorConfig != null) {
|
|
51
|
+
LinearProgressIndicator(
|
|
52
|
+
progress = { props.progress },
|
|
53
|
+
color = color,
|
|
54
|
+
trackColor = trackColor,
|
|
55
|
+
strokeCap = strokeCap,
|
|
56
|
+
gapSize = gapSize,
|
|
57
|
+
drawStopIndicator = {
|
|
58
|
+
ProgressIndicatorDefaults.drawStopIndicator(
|
|
59
|
+
drawScope = this,
|
|
60
|
+
stopSize = stopIndicatorConfig.stopSize?.dp ?: ProgressIndicatorDefaults.LinearTrackStopIndicatorSize,
|
|
61
|
+
color = stopIndicatorConfig.color.composeOrNull ?: color,
|
|
62
|
+
strokeCap = stopIndicatorConfig.strokeCap.toStrokeCap() ?: strokeCap
|
|
63
|
+
)
|
|
64
|
+
},
|
|
65
|
+
modifier = modifier
|
|
66
|
+
)
|
|
67
|
+
} else {
|
|
68
|
+
LinearProgressIndicator(
|
|
69
|
+
progress = { props.progress },
|
|
70
|
+
color = color,
|
|
71
|
+
trackColor = trackColor,
|
|
72
|
+
strokeCap = strokeCap,
|
|
73
|
+
gapSize = gapSize,
|
|
74
|
+
modifier = modifier
|
|
75
|
+
)
|
|
117
76
|
}
|
|
77
|
+
} else {
|
|
78
|
+
LinearProgressIndicator(
|
|
79
|
+
color = color,
|
|
80
|
+
trackColor = trackColor,
|
|
81
|
+
strokeCap = strokeCap,
|
|
82
|
+
gapSize = gapSize,
|
|
83
|
+
modifier = modifier
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// endregion
|
|
89
|
+
|
|
90
|
+
// region CircularProgressIndicator
|
|
91
|
+
|
|
92
|
+
data class CircularProgressIndicatorProps(
|
|
93
|
+
val progress: Float? = null,
|
|
94
|
+
val color: Color? = null,
|
|
95
|
+
val trackColor: Color? = null,
|
|
96
|
+
val strokeWidth: Float? = null,
|
|
97
|
+
val strokeCap: String? = null,
|
|
98
|
+
val gapSize: Float? = null,
|
|
99
|
+
val modifiers: ModifierList = emptyList()
|
|
100
|
+
) : ComposeProps
|
|
101
|
+
|
|
102
|
+
@Composable
|
|
103
|
+
fun FunctionalComposableScope.CircularProgressIndicatorContent(props: CircularProgressIndicatorProps) {
|
|
104
|
+
val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
105
|
+
val color = props.color.composeOrNull ?: ProgressIndicatorDefaults.circularColor
|
|
106
|
+
val strokeWidth = props.strokeWidth?.dp ?: ProgressIndicatorDefaults.CircularStrokeWidth
|
|
107
|
+
|
|
108
|
+
if (props.progress != null) {
|
|
109
|
+
val trackColor = props.trackColor.composeOrNull ?: ProgressIndicatorDefaults.circularDeterminateTrackColor
|
|
110
|
+
val strokeCap = props.strokeCap.toStrokeCap() ?: ProgressIndicatorDefaults.CircularDeterminateStrokeCap
|
|
111
|
+
val gapSize = props.gapSize?.dp ?: ProgressIndicatorDefaults.CircularIndicatorTrackGapSize
|
|
112
|
+
|
|
113
|
+
CircularProgressIndicator(
|
|
114
|
+
progress = { props.progress },
|
|
115
|
+
color = color,
|
|
116
|
+
trackColor = trackColor,
|
|
117
|
+
strokeWidth = strokeWidth,
|
|
118
|
+
strokeCap = strokeCap,
|
|
119
|
+
gapSize = gapSize,
|
|
120
|
+
modifier = modifier
|
|
121
|
+
)
|
|
122
|
+
} else {
|
|
123
|
+
val trackColor = props.trackColor.composeOrNull ?: ProgressIndicatorDefaults.circularIndeterminateTrackColor
|
|
124
|
+
val strokeCap = props.strokeCap.toStrokeCap() ?: ProgressIndicatorDefaults.CircularIndeterminateStrokeCap
|
|
125
|
+
|
|
126
|
+
CircularProgressIndicator(
|
|
127
|
+
color = color,
|
|
128
|
+
trackColor = trackColor,
|
|
129
|
+
strokeWidth = strokeWidth,
|
|
130
|
+
strokeCap = strokeCap,
|
|
131
|
+
modifier = modifier
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// endregion
|
|
137
|
+
|
|
138
|
+
// region LinearWavyProgressIndicator
|
|
139
|
+
|
|
140
|
+
data class LinearWavyProgressIndicatorProps(
|
|
141
|
+
val progress: Float? = null,
|
|
142
|
+
val color: Color? = null,
|
|
143
|
+
val trackColor: Color? = null,
|
|
144
|
+
val stopSize: Float? = null,
|
|
145
|
+
val modifiers: ModifierList = emptyList()
|
|
146
|
+
) : ComposeProps
|
|
147
|
+
|
|
148
|
+
@Composable
|
|
149
|
+
fun FunctionalComposableScope.LinearWavyProgressIndicatorContent(props: LinearWavyProgressIndicatorProps) {
|
|
150
|
+
val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
151
|
+
val color = props.color.composeOrNull ?: WavyProgressIndicatorDefaults.indicatorColor
|
|
152
|
+
val trackColor = props.trackColor.composeOrNull ?: WavyProgressIndicatorDefaults.trackColor
|
|
153
|
+
val stopSize = props.stopSize?.dp ?: WavyProgressIndicatorDefaults.LinearTrackStopIndicatorSize
|
|
154
|
+
|
|
155
|
+
if (props.progress != null) {
|
|
156
|
+
LinearWavyProgressIndicator(
|
|
157
|
+
progress = { props.progress },
|
|
158
|
+
color = color,
|
|
159
|
+
trackColor = trackColor,
|
|
160
|
+
stopSize = stopSize,
|
|
161
|
+
modifier = modifier
|
|
162
|
+
)
|
|
163
|
+
} else {
|
|
164
|
+
LinearWavyProgressIndicator(
|
|
165
|
+
color = color,
|
|
166
|
+
trackColor = trackColor,
|
|
167
|
+
modifier = modifier
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// endregion
|
|
173
|
+
|
|
174
|
+
// region CircularWavyProgressIndicator
|
|
175
|
+
|
|
176
|
+
data class CircularWavyProgressIndicatorProps(
|
|
177
|
+
val progress: Float? = null,
|
|
178
|
+
val color: Color? = null,
|
|
179
|
+
val trackColor: Color? = null,
|
|
180
|
+
val modifiers: ModifierList = emptyList()
|
|
181
|
+
) : ComposeProps
|
|
182
|
+
|
|
183
|
+
@Composable
|
|
184
|
+
fun FunctionalComposableScope.CircularWavyProgressIndicatorContent(props: CircularWavyProgressIndicatorProps) {
|
|
185
|
+
val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
186
|
+
val color = props.color.composeOrNull ?: ProgressIndicatorDefaults.circularColor
|
|
187
|
+
|
|
188
|
+
if (props.progress != null) {
|
|
189
|
+
val trackColor = props.trackColor.composeOrNull ?: ProgressIndicatorDefaults.circularDeterminateTrackColor
|
|
190
|
+
|
|
191
|
+
CircularWavyProgressIndicator(
|
|
192
|
+
progress = { props.progress },
|
|
193
|
+
color = color,
|
|
194
|
+
trackColor = trackColor,
|
|
195
|
+
modifier = modifier
|
|
196
|
+
)
|
|
197
|
+
} else {
|
|
198
|
+
val trackColor = props.trackColor.composeOrNull ?: ProgressIndicatorDefaults.circularIndeterminateTrackColor
|
|
199
|
+
|
|
200
|
+
CircularWavyProgressIndicator(
|
|
201
|
+
color = color,
|
|
202
|
+
trackColor = trackColor,
|
|
203
|
+
modifier = modifier
|
|
204
|
+
)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// endregion
|
|
209
|
+
|
|
210
|
+
// Utility
|
|
211
|
+
|
|
212
|
+
private fun String?.toStrokeCap(): StrokeCap? {
|
|
213
|
+
return when (this?.lowercase()) {
|
|
214
|
+
"round" -> StrokeCap.Round
|
|
215
|
+
"butt" -> StrokeCap.Butt
|
|
216
|
+
"square" -> StrokeCap.Square
|
|
217
|
+
else -> null
|
|
118
218
|
}
|
|
119
219
|
}
|
|
@@ -7,22 +7,18 @@ import expo.modules.kotlin.views.FunctionalComposableScope
|
|
|
7
7
|
|
|
8
8
|
data class RadioButtonProps(
|
|
9
9
|
val selected: Boolean = false,
|
|
10
|
-
val
|
|
10
|
+
val clickable: Boolean = true,
|
|
11
11
|
val modifiers: ModifierList = emptyList()
|
|
12
12
|
) : ComposeProps
|
|
13
13
|
|
|
14
14
|
@Composable
|
|
15
15
|
fun FunctionalComposableScope.RadioButtonContent(
|
|
16
16
|
props: RadioButtonProps,
|
|
17
|
-
|
|
17
|
+
onClick: (() -> Unit)?
|
|
18
18
|
) {
|
|
19
19
|
RadioButton(
|
|
20
20
|
selected = props.selected,
|
|
21
|
-
onClick =
|
|
22
|
-
{ onNativeClick() }
|
|
23
|
-
} else {
|
|
24
|
-
null
|
|
25
|
-
},
|
|
21
|
+
onClick = onClick,
|
|
26
22
|
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
27
23
|
)
|
|
28
24
|
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
package expo.modules.ui
|
|
2
|
+
|
|
3
|
+
import android.graphics.Color
|
|
4
|
+
import android.util.Log
|
|
5
|
+
import android.view.ViewGroup
|
|
6
|
+
import androidx.compose.material3.MultiChoiceSegmentedButtonRowScope
|
|
7
|
+
import androidx.compose.material3.SegmentedButton
|
|
8
|
+
import androidx.compose.material3.SegmentedButtonDefaults
|
|
9
|
+
import androidx.compose.material3.SingleChoiceSegmentedButtonRowScope
|
|
10
|
+
import androidx.compose.runtime.Composable
|
|
11
|
+
import expo.modules.kotlin.records.Field
|
|
12
|
+
import expo.modules.kotlin.records.Record
|
|
13
|
+
import expo.modules.kotlin.views.ComposableScope
|
|
14
|
+
|
|
15
|
+
import expo.modules.kotlin.views.ComposeProps
|
|
16
|
+
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
17
|
+
|
|
18
|
+
data class SegmentedButtonColors(
|
|
19
|
+
@Field val activeBorderColor: Color? = null,
|
|
20
|
+
@Field val activeContentColor: Color? = null,
|
|
21
|
+
@Field val inactiveBorderColor: Color? = null,
|
|
22
|
+
@Field val inactiveContentColor: Color? = null,
|
|
23
|
+
@Field val disabledActiveBorderColor: Color? = null,
|
|
24
|
+
@Field val disabledActiveContentColor: Color? = null,
|
|
25
|
+
@Field val disabledInactiveBorderColor: Color? = null,
|
|
26
|
+
@Field val disabledInactiveContentColor: Color? = null,
|
|
27
|
+
@Field val activeContainerColor: Color? = null,
|
|
28
|
+
@Field val inactiveContainerColor: Color? = null,
|
|
29
|
+
@Field val disabledActiveContainerColor: Color? = null,
|
|
30
|
+
@Field val disabledInactiveContainerColor: Color? = null
|
|
31
|
+
) : Record
|
|
32
|
+
|
|
33
|
+
data class SegmentedButtonProps(
|
|
34
|
+
val selected: Boolean = false,
|
|
35
|
+
val checked: Boolean = false,
|
|
36
|
+
val enabled: Boolean = true,
|
|
37
|
+
val colors: SegmentedButtonColors = SegmentedButtonColors(),
|
|
38
|
+
val modifiers: ModifierList = emptyList()
|
|
39
|
+
) : ComposeProps
|
|
40
|
+
|
|
41
|
+
@Composable
|
|
42
|
+
fun FunctionalComposableScope.SegmentedButtonContent(
|
|
43
|
+
props: SegmentedButtonProps,
|
|
44
|
+
onClick: () -> Unit,
|
|
45
|
+
onCheckedChange: (GenericEventPayload1<Boolean>) -> Unit
|
|
46
|
+
) {
|
|
47
|
+
val colors = props.colors
|
|
48
|
+
val labelSlotView = findChildSlotView(view, "label")
|
|
49
|
+
val parent = view.parent as? ViewGroup
|
|
50
|
+
val index = parent?.indexOfChild(view) ?: 0
|
|
51
|
+
val count = parent?.childCount ?: 1
|
|
52
|
+
|
|
53
|
+
val segmentedColors = SegmentedButtonDefaults.colors(
|
|
54
|
+
activeBorderColor = colors.activeBorderColor.compose,
|
|
55
|
+
activeContentColor = colors.activeContentColor.compose,
|
|
56
|
+
inactiveBorderColor = colors.inactiveBorderColor.compose,
|
|
57
|
+
inactiveContentColor = colors.inactiveContentColor.compose,
|
|
58
|
+
disabledActiveBorderColor = colors.disabledActiveBorderColor.compose,
|
|
59
|
+
disabledActiveContentColor = colors.disabledActiveContentColor.compose,
|
|
60
|
+
disabledInactiveBorderColor = colors.disabledInactiveBorderColor.compose,
|
|
61
|
+
disabledInactiveContentColor = colors.disabledInactiveContentColor.compose,
|
|
62
|
+
activeContainerColor = colors.activeContainerColor.compose,
|
|
63
|
+
inactiveContainerColor = colors.inactiveContainerColor.compose,
|
|
64
|
+
disabledActiveContainerColor = colors.disabledActiveContainerColor.compose,
|
|
65
|
+
disabledInactiveContainerColor = colors.disabledInactiveContainerColor.compose
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
val shape = SegmentedButtonDefaults.itemShape(index = index, count = count)
|
|
69
|
+
val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
70
|
+
val label: @Composable () -> Unit = labelSlotView?.let {
|
|
71
|
+
{
|
|
72
|
+
with(ComposableScope()) {
|
|
73
|
+
with(it) {
|
|
74
|
+
Content()
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
} ?: {}
|
|
79
|
+
|
|
80
|
+
val singleScope = composableScope.rowScope as? SingleChoiceSegmentedButtonRowScope
|
|
81
|
+
val multiScope = composableScope.rowScope as? MultiChoiceSegmentedButtonRowScope
|
|
82
|
+
|
|
83
|
+
if (singleScope == null && multiScope == null) {
|
|
84
|
+
if (BuildConfig.DEBUG) {
|
|
85
|
+
Log.w("ExpoUI", "SegmentedButton must be used within a SingleChoiceSegmentedButtonRow or MultiChoiceSegmentedButtonRow. It will not render on its own.")
|
|
86
|
+
}
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (singleScope != null) {
|
|
91
|
+
with(singleScope) {
|
|
92
|
+
SegmentedButton(
|
|
93
|
+
selected = props.selected,
|
|
94
|
+
onClick = onClick,
|
|
95
|
+
shape = shape,
|
|
96
|
+
enabled = props.enabled,
|
|
97
|
+
colors = segmentedColors,
|
|
98
|
+
modifier = modifier,
|
|
99
|
+
label = label
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
} else if (multiScope != null) {
|
|
103
|
+
with(multiScope) {
|
|
104
|
+
SegmentedButton(
|
|
105
|
+
checked = props.checked,
|
|
106
|
+
onCheckedChange = { onCheckedChange(GenericEventPayload1(it)) },
|
|
107
|
+
shape = shape,
|
|
108
|
+
enabled = props.enabled,
|
|
109
|
+
colors = segmentedColors,
|
|
110
|
+
modifier = modifier,
|
|
111
|
+
label = label
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
package expo.modules.ui
|
|
2
|
+
|
|
3
|
+
import androidx.compose.material3.MultiChoiceSegmentedButtonRow
|
|
4
|
+
import androidx.compose.material3.SingleChoiceSegmentedButtonRow
|
|
5
|
+
import androidx.compose.runtime.Composable
|
|
6
|
+
import expo.modules.kotlin.views.ComposableScope
|
|
7
|
+
import expo.modules.kotlin.views.ComposeProps
|
|
8
|
+
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
9
|
+
import expo.modules.kotlin.views.with
|
|
10
|
+
|
|
11
|
+
data class SingleChoiceSegmentedButtonRowProps(
|
|
12
|
+
val modifiers: ModifierList = emptyList()
|
|
13
|
+
) : ComposeProps
|
|
14
|
+
|
|
15
|
+
@Composable
|
|
16
|
+
fun FunctionalComposableScope.SingleChoiceSegmentedButtonRowContent(props: SingleChoiceSegmentedButtonRowProps) {
|
|
17
|
+
SingleChoiceSegmentedButtonRow(
|
|
18
|
+
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
19
|
+
) {
|
|
20
|
+
Children(ComposableScope().with(rowScope = this@SingleChoiceSegmentedButtonRow))
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
data class MultiChoiceSegmentedButtonRowProps(
|
|
25
|
+
val modifiers: ModifierList = emptyList()
|
|
26
|
+
) : ComposeProps
|
|
27
|
+
|
|
28
|
+
@Composable
|
|
29
|
+
fun FunctionalComposableScope.MultiChoiceSegmentedButtonRowContent(props: MultiChoiceSegmentedButtonRowProps) {
|
|
30
|
+
MultiChoiceSegmentedButtonRow(
|
|
31
|
+
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
32
|
+
) {
|
|
33
|
+
Children(ComposableScope().with(rowScope = this@MultiChoiceSegmentedButtonRow))
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
package expo.modules.ui
|
|
2
2
|
|
|
3
3
|
import android.graphics.Color
|
|
4
|
+
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
5
|
+
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
4
6
|
import androidx.compose.material3.Slider
|
|
5
7
|
import androidx.compose.material3.SliderDefaults
|
|
6
8
|
import androidx.compose.runtime.Composable
|
|
9
|
+
import androidx.compose.runtime.getValue
|
|
10
|
+
import androidx.compose.runtime.mutableFloatStateOf
|
|
11
|
+
import androidx.compose.runtime.mutableStateOf
|
|
7
12
|
import androidx.compose.runtime.remember
|
|
13
|
+
import androidx.compose.runtime.setValue
|
|
8
14
|
import expo.modules.kotlin.records.Field
|
|
9
15
|
import expo.modules.kotlin.records.Record
|
|
10
16
|
import expo.modules.kotlin.viewevent.getValue
|
|
17
|
+
import expo.modules.kotlin.views.ComposableScope
|
|
11
18
|
import expo.modules.kotlin.views.ComposeProps
|
|
12
19
|
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
13
20
|
|
|
@@ -33,7 +40,8 @@ data class SliderProps(
|
|
|
33
40
|
val min: Float = 0.0f,
|
|
34
41
|
val max: Float = 1.0f,
|
|
35
42
|
val steps: Int = 0,
|
|
36
|
-
val
|
|
43
|
+
val enabled: Boolean = true,
|
|
44
|
+
val colors: SliderColors = SliderColors(),
|
|
37
45
|
val modifiers: ModifierList = emptyList()
|
|
38
46
|
) : ComposeProps
|
|
39
47
|
|
|
@@ -41,24 +49,74 @@ data class SliderValueChangedEvent(
|
|
|
41
49
|
@Field val value: Float
|
|
42
50
|
) : Record
|
|
43
51
|
|
|
52
|
+
@OptIn(ExperimentalMaterial3Api::class)
|
|
44
53
|
@Composable
|
|
45
54
|
fun FunctionalComposableScope.SliderContent(props: SliderProps) {
|
|
46
|
-
val
|
|
47
|
-
val
|
|
55
|
+
val onValueChange by remember { this@SliderContent.EventDispatcher<SliderValueChangedEvent>() }
|
|
56
|
+
val onValueChangeFinished by remember { this@SliderContent.EventDispatcher<Unit>() }
|
|
57
|
+
val interactionSource = remember { MutableInteractionSource() }
|
|
58
|
+
|
|
59
|
+
var localValue by remember { mutableFloatStateOf(props.value.coerceIn(props.min, props.max)) }
|
|
60
|
+
var isDragging by remember { mutableStateOf(false) }
|
|
61
|
+
val clampedPropsValue = props.value.coerceIn(props.min, props.max)
|
|
62
|
+
var prevPropsValue by remember { mutableFloatStateOf(clampedPropsValue) }
|
|
63
|
+
|
|
64
|
+
if (clampedPropsValue != prevPropsValue) {
|
|
65
|
+
prevPropsValue = clampedPropsValue
|
|
66
|
+
if (!isDragging) {
|
|
67
|
+
localValue = clampedPropsValue
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
val thumbSlotView = findChildSlotView(view, "thumb")
|
|
72
|
+
val trackSlotView = findChildSlotView(view, "track")
|
|
73
|
+
|
|
74
|
+
val sliderColors = SliderDefaults.colors(
|
|
75
|
+
thumbColor = props.colors.thumbColor.compose,
|
|
76
|
+
activeTrackColor = props.colors.activeTrackColor.compose,
|
|
77
|
+
inactiveTrackColor = props.colors.inactiveTrackColor.compose,
|
|
78
|
+
activeTickColor = props.colors.activeTickColor.compose,
|
|
79
|
+
inactiveTickColor = props.colors.inactiveTickColor.compose
|
|
80
|
+
)
|
|
81
|
+
|
|
48
82
|
Slider(
|
|
49
|
-
value =
|
|
83
|
+
value = localValue,
|
|
50
84
|
valueRange = props.min..props.max,
|
|
51
85
|
steps = props.steps,
|
|
86
|
+
enabled = props.enabled,
|
|
87
|
+
interactionSource = interactionSource,
|
|
52
88
|
onValueChange = {
|
|
53
|
-
|
|
89
|
+
isDragging = true
|
|
90
|
+
localValue = it
|
|
91
|
+
onValueChange(SliderValueChangedEvent(it))
|
|
92
|
+
},
|
|
93
|
+
onValueChangeFinished = {
|
|
94
|
+
isDragging = false
|
|
95
|
+
onValueChangeFinished(Unit)
|
|
96
|
+
},
|
|
97
|
+
colors = sliderColors,
|
|
98
|
+
thumb = { sliderState ->
|
|
99
|
+
if (thumbSlotView != null) {
|
|
100
|
+
with(ComposableScope()) { with(thumbSlotView) { Content() } }
|
|
101
|
+
} else {
|
|
102
|
+
SliderDefaults.Thumb(
|
|
103
|
+
interactionSource = interactionSource,
|
|
104
|
+
colors = sliderColors,
|
|
105
|
+
enabled = props.enabled
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
track = { sliderState ->
|
|
110
|
+
if (trackSlotView != null) {
|
|
111
|
+
with(ComposableScope()) { with(trackSlotView) { Content() } }
|
|
112
|
+
} else {
|
|
113
|
+
SliderDefaults.Track(
|
|
114
|
+
sliderState = sliderState,
|
|
115
|
+
colors = sliderColors,
|
|
116
|
+
enabled = props.enabled
|
|
117
|
+
)
|
|
118
|
+
}
|
|
54
119
|
},
|
|
55
|
-
colors = SliderDefaults.colors(
|
|
56
|
-
thumbColor = colors.thumbColor.compose,
|
|
57
|
-
activeTrackColor = colors.activeTrackColor.compose,
|
|
58
|
-
inactiveTrackColor = colors.inactiveTrackColor.compose,
|
|
59
|
-
activeTickColor = colors.activeTickColor.compose,
|
|
60
|
-
inactiveTickColor = colors.inactiveTickColor.compose
|
|
61
|
-
),
|
|
62
120
|
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
63
121
|
)
|
|
64
122
|
}
|