glacia-native 0.5.0 → 0.5.2
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/LICENSE +29 -4
- package/README.md +27 -0
- package/lib/module/Bars.js +103 -9
- package/lib/module/Button.js +11 -8
- package/lib/module/Card.js +2 -2
- package/lib/module/Dialog.js +16 -17
- package/lib/module/Display.js +86 -8
- package/lib/module/Feedback.js +244 -21
- package/lib/module/Form.js +29 -33
- package/lib/module/Forms2.js +257 -13
- package/lib/module/Glass.js +2 -2
- package/lib/module/Input.js +12 -10
- package/lib/module/Message.js +84 -0
- package/lib/module/Overlays.js +195 -17
- package/lib/module/Pickers.js +16 -16
- package/lib/module/SegmentedControl.js +24 -11
- package/lib/module/Slider.js +24 -10
- package/lib/module/Switch.js +25 -10
- package/lib/module/TabBar.js +23 -13
- package/lib/module/Table.js +4 -3
- package/lib/module/Tabs.js +3 -2
- package/lib/module/ai.js +26 -18
- package/lib/module/charts/BarChart.js +11 -3
- package/lib/module/index.js +23 -2
- package/lib/module/internal/GlassContainer.js +54 -0
- package/lib/module/internal/GlassView.js +10 -2
- package/lib/module/internal/a11y.js +94 -0
- package/lib/module/internal/blur.js +78 -0
- package/lib/module/internal/fallback.js +120 -19
- package/lib/module/internal/glass-routing.js +7 -0
- package/lib/module/internal/glow.js +36 -0
- package/lib/module/internal/haptics.js +54 -0
- package/lib/module/internal/lens.js +70 -0
- package/lib/module/internal/material.js +64 -0
- package/lib/module/internal/motion.js +10 -1
- package/lib/module/internal/primitives.js +70 -4
- package/lib/module/internal/rim.js +35 -0
- package/lib/module/internal/tokens.js +80 -2
- package/lib/typescript/Bars.d.ts +67 -0
- package/lib/typescript/Display.d.ts +59 -0
- package/lib/typescript/Feedback.d.ts +58 -0
- package/lib/typescript/Forms2.d.ts +81 -0
- package/lib/typescript/Message.d.ts +67 -0
- package/lib/typescript/Overlays.d.ts +41 -0
- package/lib/typescript/SegmentedControl.d.ts +2 -0
- package/lib/typescript/Slider.d.ts +2 -0
- package/lib/typescript/Switch.d.ts +2 -0
- package/lib/typescript/TabBar.d.ts +2 -0
- package/lib/typescript/index.d.ts +9 -6
- package/lib/typescript/internal/GlassContainer.d.ts +37 -0
- package/lib/typescript/internal/GlassView.d.ts +21 -0
- package/lib/typescript/internal/a11y.d.ts +19 -0
- package/lib/typescript/internal/blur.d.ts +24 -0
- package/lib/typescript/internal/fallback.d.ts +32 -2
- package/lib/typescript/internal/glass-routing.d.ts +10 -0
- package/lib/typescript/internal/glow.d.ts +11 -0
- package/lib/typescript/internal/haptics.d.ts +7 -0
- package/lib/typescript/internal/lens.d.ts +47 -0
- package/lib/typescript/internal/material.d.ts +27 -0
- package/lib/typescript/internal/motion.d.ts +4 -0
- package/lib/typescript/internal/primitives.d.ts +23 -0
- package/lib/typescript/internal/rim.d.ts +16 -0
- package/lib/typescript/internal/tokens.d.ts +89 -0
- package/package.json +12 -3
- package/src/Bars.tsx +239 -2
- package/src/Button.tsx +16 -9
- package/src/Card.tsx +2 -2
- package/src/Dialog.tsx +37 -26
- package/src/Display.tsx +237 -6
- package/src/Feedback.tsx +448 -35
- package/src/Form.tsx +60 -40
- package/src/Forms2.tsx +455 -8
- package/src/Glass.tsx +4 -0
- package/src/Input.tsx +15 -11
- package/src/Message.tsx +218 -0
- package/src/Overlays.tsx +269 -39
- package/src/Pickers.tsx +11 -6
- package/src/SegmentedControl.tsx +39 -9
- package/src/Slider.tsx +26 -10
- package/src/Switch.tsx +29 -10
- package/src/TabBar.tsx +39 -12
- package/src/Table.tsx +4 -3
- package/src/Tabs.tsx +5 -0
- package/src/ai.tsx +37 -23
- package/src/charts/BarChart.tsx +41 -3
- package/src/index.ts +43 -1
- package/src/internal/GlassContainer.tsx +82 -0
- package/src/internal/GlassView.tsx +25 -0
- package/src/internal/a11y.ts +105 -0
- package/src/internal/blur.ts +90 -0
- package/src/internal/fallback.tsx +170 -15
- package/src/internal/glass-routing.ts +17 -0
- package/src/internal/glow.tsx +62 -0
- package/src/internal/haptics.ts +59 -0
- package/src/internal/lens.tsx +105 -0
- package/src/internal/material.ts +92 -0
- package/src/internal/motion.ts +10 -1
- package/src/internal/primitives.ts +83 -4
- package/src/internal/rim.tsx +79 -0
- package/src/internal/tokens.ts +82 -1
package/src/Bars.tsx
CHANGED
|
@@ -74,6 +74,7 @@ export const SearchBar = forwardRef<any, SearchBarProps>(function SearchBar(
|
|
|
74
74
|
>
|
|
75
75
|
<Glass
|
|
76
76
|
effect="regular"
|
|
77
|
+
surface="field"
|
|
77
78
|
isDark={isDark}
|
|
78
79
|
style={{
|
|
79
80
|
flex: 1,
|
|
@@ -204,6 +205,7 @@ export const Chip = forwardRef<any, ChipProps>(function Chip(
|
|
|
204
205
|
const { View, Text: RNText, Pressable } = primitives();
|
|
205
206
|
|
|
206
207
|
const [internalSelected, setInternalSelected] = useState(defaultSelected);
|
|
208
|
+
const [held, setHeld] = useState(false);
|
|
207
209
|
const selected = selectedProp !== undefined ? selectedProp : internalSelected;
|
|
208
210
|
const selectable = selectedProp !== undefined || onSelectedChange !== undefined || defaultSelected;
|
|
209
211
|
|
|
@@ -220,6 +222,8 @@ export const Chip = forwardRef<any, ChipProps>(function Chip(
|
|
|
220
222
|
const pill = (
|
|
221
223
|
<Glass
|
|
222
224
|
effect="regular"
|
|
225
|
+
surface="control"
|
|
226
|
+
pressed={held}
|
|
223
227
|
isDark={isDark}
|
|
224
228
|
tintColor={selected ? theme.glassActive : undefined}
|
|
225
229
|
interactive={!disabled}
|
|
@@ -227,7 +231,7 @@ export const Chip = forwardRef<any, ChipProps>(function Chip(
|
|
|
227
231
|
flexDirection: "row",
|
|
228
232
|
alignItems: "center",
|
|
229
233
|
gap: 6,
|
|
230
|
-
height:
|
|
234
|
+
height: 34,
|
|
231
235
|
paddingHorizontal: 12,
|
|
232
236
|
borderRadius: radii.pill,
|
|
233
237
|
opacity: disabled ? 0.38 : 1,
|
|
@@ -237,7 +241,7 @@ export const Chip = forwardRef<any, ChipProps>(function Chip(
|
|
|
237
241
|
{icon ? <View>{icon}</View> : null}
|
|
238
242
|
<RNText
|
|
239
243
|
numberOfLines={1}
|
|
240
|
-
style={{ fontSize:
|
|
244
|
+
style={{ fontSize: 14, fontWeight: selected ? "600" : "500", color: selected ? theme.foreground : theme.muted }}
|
|
241
245
|
>
|
|
242
246
|
{label}
|
|
243
247
|
</RNText>
|
|
@@ -344,6 +348,7 @@ export const FAB = forwardRef<any, FABProps>(function FAB(
|
|
|
344
348
|
>
|
|
345
349
|
<Glass
|
|
346
350
|
effect="clear"
|
|
351
|
+
surface="control"
|
|
347
352
|
interactive={!disabled}
|
|
348
353
|
isDark={isDark}
|
|
349
354
|
style={{
|
|
@@ -428,6 +433,7 @@ export const IconButton = forwardRef<any, IconButtonProps>(function IconButton(
|
|
|
428
433
|
>
|
|
429
434
|
<Glass
|
|
430
435
|
effect={variant === "ghost" ? "none" : "regular"}
|
|
436
|
+
surface="control"
|
|
431
437
|
interactive={!disabled && variant !== "ghost"}
|
|
432
438
|
isDark={isDark}
|
|
433
439
|
style={{
|
|
@@ -473,6 +479,15 @@ export interface AppBarProps {
|
|
|
473
479
|
* knows its insets, and passing a number keeps this component dependency-free.
|
|
474
480
|
*/
|
|
475
481
|
topInset?: number;
|
|
482
|
+
/**
|
|
483
|
+
* Whether content has scrolled under the bar.
|
|
484
|
+
*
|
|
485
|
+
* iOS bars sit quiet at the top of a screen and gain a defined edge once
|
|
486
|
+
* content passes beneath them, so the bar reads as a layer over the content
|
|
487
|
+
* rather than as part of it. Wire this to a ScrollView's scroll offset — see
|
|
488
|
+
* the component's documentation for the two-line version.
|
|
489
|
+
*/
|
|
490
|
+
scrolled?: boolean;
|
|
476
491
|
style?: StyleProp<ViewStyle>;
|
|
477
492
|
isDark?: boolean;
|
|
478
493
|
testID?: string;
|
|
@@ -483,6 +498,19 @@ export interface AppBarProps {
|
|
|
483
498
|
*
|
|
484
499
|
* A glass bar across the top of the screen with a leading action, a title and
|
|
485
500
|
* trailing actions — the counterpart to the existing bottom TabBar.
|
|
501
|
+
*
|
|
502
|
+
* `scrolled` mirrors iOS 26's scroll-edge effect. At the top of the screen the
|
|
503
|
+
* bar is quiet: its bottom edge is invisible and the glass blends into the
|
|
504
|
+
* content above it. Once content has scrolled under it, the edge token becomes
|
|
505
|
+
* visible and the surface reads as a distinct layer — the change iOS makes when
|
|
506
|
+
* a navigation bar starts floating over scrolled content.
|
|
507
|
+
*
|
|
508
|
+
* ```
|
|
509
|
+
* const [scrolled, setScrolled] = useState(false);
|
|
510
|
+
* <ScrollView onScroll={(e) => setScrolled(e.nativeEvent.contentOffset.y > 8)}
|
|
511
|
+
* scrollEventThrottle={16}>{...}</ScrollView>
|
|
512
|
+
* <AppBar title="Inbox" scrolled={scrolled} />
|
|
513
|
+
* ```
|
|
486
514
|
*/
|
|
487
515
|
export const AppBar = forwardRef<any, AppBarProps>(function AppBar(
|
|
488
516
|
{
|
|
@@ -491,6 +519,7 @@ export const AppBar = forwardRef<any, AppBarProps>(function AppBar(
|
|
|
491
519
|
leading,
|
|
492
520
|
actions,
|
|
493
521
|
topInset = 0,
|
|
522
|
+
scrolled = false,
|
|
494
523
|
style,
|
|
495
524
|
isDark: isDarkProp,
|
|
496
525
|
testID,
|
|
@@ -522,6 +551,7 @@ export const AppBar = forwardRef<any, AppBarProps>(function AppBar(
|
|
|
522
551
|
<Glass
|
|
523
552
|
ref={ref}
|
|
524
553
|
effect="regular"
|
|
554
|
+
surface="rail"
|
|
525
555
|
isDark={isDark}
|
|
526
556
|
testID={testID}
|
|
527
557
|
style={{
|
|
@@ -529,6 +559,9 @@ export const AppBar = forwardRef<any, AppBarProps>(function AppBar(
|
|
|
529
559
|
borderTopWidth: 0,
|
|
530
560
|
borderLeftWidth: 0,
|
|
531
561
|
borderRightWidth: 0,
|
|
562
|
+
// Quiet at the top of a screen, defined once content is under it: the
|
|
563
|
+
// bottom edge is the difference iOS draws on a scrolled navigation bar.
|
|
564
|
+
...(scrolled ? { borderBottomWidth: 0.5, borderBottomColor: theme.edge } : { borderBottomWidth: 0 }),
|
|
532
565
|
...(style as ViewStyle),
|
|
533
566
|
}}
|
|
534
567
|
{...props}
|
|
@@ -568,3 +601,207 @@ export const AppBar = forwardRef<any, AppBarProps>(function AppBar(
|
|
|
568
601
|
</Glass>
|
|
569
602
|
);
|
|
570
603
|
});
|
|
604
|
+
|
|
605
|
+
// ---------------------------------------------------------------------------
|
|
606
|
+
// FABGroup
|
|
607
|
+
|
|
608
|
+
export interface FABGroupAction {
|
|
609
|
+
/** A leading node, typically an SVG icon the caller supplies. */
|
|
610
|
+
icon: ReactNode;
|
|
611
|
+
/** The action's name, shown on its mini button. */
|
|
612
|
+
label: string;
|
|
613
|
+
onPress: () => void;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
export interface FABGroupProps {
|
|
617
|
+
/** The actions, listed top to bottom as they appear when expanded. */
|
|
618
|
+
actions: FABGroupAction[];
|
|
619
|
+
/** The icon on the main button. Rotates 45° while open. */
|
|
620
|
+
icon: ReactNode;
|
|
621
|
+
/** The icon on the main button while open. Defaults to the closed one. */
|
|
622
|
+
closeIcon?: ReactNode;
|
|
623
|
+
/** Controlled open state. Omit and the group keeps its own. */
|
|
624
|
+
open?: boolean;
|
|
625
|
+
defaultOpen?: boolean;
|
|
626
|
+
onOpenChange?: (open: boolean) => void;
|
|
627
|
+
/** The main button's accessible name. */
|
|
628
|
+
accessibilityLabel?: string;
|
|
629
|
+
size?: "md" | "lg";
|
|
630
|
+
style?: StyleProp<ViewStyle>;
|
|
631
|
+
isDark?: boolean;
|
|
632
|
+
testID?: string;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// The main button's size, and the mini buttons' — both from the size scale so
|
|
636
|
+
// a mini button is never a hand-tuned multiple of the main one.
|
|
637
|
+
const fabGroupSizes = {
|
|
638
|
+
md: { main: 56, mini: 44 },
|
|
639
|
+
lg: { main: 64, mini: 52 },
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* A main button that expands into a stack of labelled mini buttons.
|
|
644
|
+
*
|
|
645
|
+
* The pattern Paper calls `FAB.Group`: one floating button stands in for a set
|
|
646
|
+
* of actions until it is opened, then the actions appear above it, each on its
|
|
647
|
+
* own glass pill with a label. A scrim behind them takes the next press and
|
|
648
|
+
* closes the group, which is how a floating action set gets out of the way
|
|
649
|
+
* without a dismissal button.
|
|
650
|
+
*
|
|
651
|
+
* The mini buttons rise on the bouncy spring with a small stagger, and the main
|
|
652
|
+
* button's icon rotates 45° — both settle instantly under Reduce Motion.
|
|
653
|
+
*
|
|
654
|
+
* **Merging is an iOS 26+ visual effect.** This component is one glass surface
|
|
655
|
+
* plus one per action; to have them blend into a single connected surface, put
|
|
656
|
+
* the group inside a `GlassContainer` on iOS 26. It works standalone — nothing
|
|
657
|
+
* depends on the container — and that composition is left to the caller rather
|
|
658
|
+
* than forced, because a group outside a container is the correct rendering on
|
|
659
|
+
* every other platform anyway.
|
|
660
|
+
*/
|
|
661
|
+
export const FABGroup = forwardRef<any, FABGroupProps>(function FABGroup(
|
|
662
|
+
{
|
|
663
|
+
actions,
|
|
664
|
+
icon,
|
|
665
|
+
closeIcon,
|
|
666
|
+
open: openProp,
|
|
667
|
+
defaultOpen = false,
|
|
668
|
+
onOpenChange,
|
|
669
|
+
accessibilityLabel = "More actions",
|
|
670
|
+
size = "md",
|
|
671
|
+
style,
|
|
672
|
+
isDark: isDarkProp,
|
|
673
|
+
testID,
|
|
674
|
+
...props
|
|
675
|
+
},
|
|
676
|
+
ref,
|
|
677
|
+
) {
|
|
678
|
+
const isDark = useIsDark(isDarkProp);
|
|
679
|
+
const theme = isDark ? colors.dark : colors.light;
|
|
680
|
+
const { View, Text: RNText, Pressable, Animated } = primitives();
|
|
681
|
+
|
|
682
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
683
|
+
const open = openProp !== undefined ? openProp : internalOpen;
|
|
684
|
+
|
|
685
|
+
const setOpen = (next: boolean) => {
|
|
686
|
+
if (openProp === undefined) setInternalOpen(next);
|
|
687
|
+
onOpenChange?.(next);
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
// The stack's rise is one value: 0 closed, 1 open. The mini buttons ride it
|
|
691
|
+
// with their own stagger, so they follow the lead rather than all snapping
|
|
692
|
+
// at once.
|
|
693
|
+
const { value: rise, animated } = useSpring(open ? 1 : 0, "bouncy");
|
|
694
|
+
|
|
695
|
+
const { main: dimension, mini } = fabGroupSizes[size];
|
|
696
|
+
const closeFirst = closeIcon ?? icon;
|
|
697
|
+
|
|
698
|
+
const rotate = animated ? rise.interpolate({ inputRange: [0, 1], outputRange: ["0deg", "45deg"] }) : open ? "45deg" : "0deg";
|
|
699
|
+
|
|
700
|
+
return (
|
|
701
|
+
<View ref={ref} testID={testID} style={style} {...props}>
|
|
702
|
+
{open ? (
|
|
703
|
+
<Pressable
|
|
704
|
+
accessibilityRole="button"
|
|
705
|
+
accessibilityLabel="Close actions"
|
|
706
|
+
onPress={() => setOpen(false)}
|
|
707
|
+
style={{ position: "absolute", top: -2000, left: -2000, right: -2000, bottom: -2000, backgroundColor: theme.scrim }}
|
|
708
|
+
/>
|
|
709
|
+
) : null}
|
|
710
|
+
|
|
711
|
+
<View style={{ alignItems: "flex-end", gap: 10 }}>
|
|
712
|
+
{open
|
|
713
|
+
? actions.map((action, index) => {
|
|
714
|
+
// Later actions sit higher, so the first is nearest the button.
|
|
715
|
+
const order = actions.length - 1 - index;
|
|
716
|
+
const translateY = animated
|
|
717
|
+
? rise.interpolate({
|
|
718
|
+
inputRange: [0, 1],
|
|
719
|
+
outputRange: [24 + order * 18, 0],
|
|
720
|
+
})
|
|
721
|
+
: 0;
|
|
722
|
+
const opacity = animated ? rise.interpolate({ inputRange: [0, 0.4, 1], outputRange: [0, 0, 1] }) : 1;
|
|
723
|
+
|
|
724
|
+
const pill = (
|
|
725
|
+
<Pressable
|
|
726
|
+
accessibilityRole="button"
|
|
727
|
+
accessibilityLabel={action.label}
|
|
728
|
+
onPress={() => {
|
|
729
|
+
setOpen(false);
|
|
730
|
+
action.onPress();
|
|
731
|
+
}}
|
|
732
|
+
style={{ flexDirection: "row", alignItems: "center", gap: 8 }}
|
|
733
|
+
>
|
|
734
|
+
<Glass
|
|
735
|
+
effect="regular"
|
|
736
|
+
surface="control"
|
|
737
|
+
isDark={isDark}
|
|
738
|
+
style={{ borderRadius: radii.pill, paddingHorizontal: 12, paddingVertical: 7 }}
|
|
739
|
+
>
|
|
740
|
+
<RNText style={{ fontSize: 13, fontWeight: "600", color: theme.foreground }} numberOfLines={1}>
|
|
741
|
+
{action.label}
|
|
742
|
+
</RNText>
|
|
743
|
+
</Glass>
|
|
744
|
+
<Glass
|
|
745
|
+
effect="regular"
|
|
746
|
+
surface="control"
|
|
747
|
+
isDark={isDark}
|
|
748
|
+
style={{
|
|
749
|
+
width: mini,
|
|
750
|
+
height: mini,
|
|
751
|
+
borderRadius: mini / 2,
|
|
752
|
+
alignItems: "center",
|
|
753
|
+
justifyContent: "center",
|
|
754
|
+
}}
|
|
755
|
+
>
|
|
756
|
+
{action.icon}
|
|
757
|
+
</Glass>
|
|
758
|
+
</Pressable>
|
|
759
|
+
);
|
|
760
|
+
|
|
761
|
+
if (!animated) {
|
|
762
|
+
return (
|
|
763
|
+
<View key={`${action.label}-${index}`}>{pill}</View>
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
return (
|
|
768
|
+
<Animated.View
|
|
769
|
+
key={`${action.label}-${index}`}
|
|
770
|
+
style={{ transform: [{ translateY }], opacity }}
|
|
771
|
+
>
|
|
772
|
+
{pill}
|
|
773
|
+
</Animated.View>
|
|
774
|
+
);
|
|
775
|
+
})
|
|
776
|
+
: null}
|
|
777
|
+
|
|
778
|
+
<Pressable
|
|
779
|
+
accessibilityRole="button"
|
|
780
|
+
accessibilityLabel={accessibilityLabel}
|
|
781
|
+
accessibilityState={{ expanded: open }}
|
|
782
|
+
onPress={() => setOpen(!open)}
|
|
783
|
+
>
|
|
784
|
+
<Glass
|
|
785
|
+
effect="clear"
|
|
786
|
+
surface="control"
|
|
787
|
+
interactive
|
|
788
|
+
isDark={isDark}
|
|
789
|
+
style={{
|
|
790
|
+
width: dimension,
|
|
791
|
+
height: dimension,
|
|
792
|
+
borderRadius: dimension / 2,
|
|
793
|
+
alignItems: "center",
|
|
794
|
+
justifyContent: "center",
|
|
795
|
+
}}
|
|
796
|
+
>
|
|
797
|
+
{animated ? (
|
|
798
|
+
<Animated.View style={{ transform: [{ rotate }] }}>{open ? closeFirst : icon}</Animated.View>
|
|
799
|
+
) : (
|
|
800
|
+
<View>{open ? closeFirst : icon}</View>
|
|
801
|
+
)}
|
|
802
|
+
</Glass>
|
|
803
|
+
</Pressable>
|
|
804
|
+
</View>
|
|
805
|
+
</View>
|
|
806
|
+
);
|
|
807
|
+
});
|
package/src/Button.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef, type ReactNode } from "react";
|
|
1
|
+
import { forwardRef, useState, type ReactNode } from "react";
|
|
2
2
|
import type { StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { Glass } from "./Glass";
|
|
@@ -21,10 +21,12 @@ export interface ButtonProps {
|
|
|
21
21
|
testID?: string;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
// The web control scale: 28 / 34 / 44, one horizontal padding and one type
|
|
25
|
+
// size for every button, and the inherited 400 weight rather than a 500.
|
|
24
26
|
const sizeHeights = {
|
|
25
|
-
sm:
|
|
26
|
-
md:
|
|
27
|
-
lg:
|
|
27
|
+
sm: 28,
|
|
28
|
+
md: 34,
|
|
29
|
+
lg: 44,
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
/**
|
|
@@ -54,6 +56,7 @@ export const Button = forwardRef<any, ButtonProps>(function Button(
|
|
|
54
56
|
const isDark = useIsDark(isDarkProp);
|
|
55
57
|
const themeColors = isDark ? colors.dark : colors.light;
|
|
56
58
|
const { Pressable, View, Text } = primitives();
|
|
59
|
+
const [held, setHeld] = useState(false);
|
|
57
60
|
const height = sizeHeights[size];
|
|
58
61
|
|
|
59
62
|
const buttonStyle: ViewStyle = {
|
|
@@ -62,7 +65,7 @@ export const Button = forwardRef<any, ButtonProps>(function Button(
|
|
|
62
65
|
flexDirection: "row",
|
|
63
66
|
alignItems: "center",
|
|
64
67
|
justifyContent: "center",
|
|
65
|
-
paddingHorizontal:
|
|
68
|
+
paddingHorizontal: 14,
|
|
66
69
|
opacity: disabled ? 0.38 : 1,
|
|
67
70
|
backgroundColor:
|
|
68
71
|
variant === "filled"
|
|
@@ -74,9 +77,9 @@ export const Button = forwardRef<any, ButtonProps>(function Button(
|
|
|
74
77
|
};
|
|
75
78
|
|
|
76
79
|
const textStyle: TextStyle = {
|
|
77
|
-
color: variant === "filled" ?
|
|
78
|
-
fontSize:
|
|
79
|
-
fontWeight: "
|
|
80
|
+
color: variant === "filled" ? themeColors.onTint : tint || themeColors.foreground,
|
|
81
|
+
fontSize: 14,
|
|
82
|
+
fontWeight: "400",
|
|
80
83
|
};
|
|
81
84
|
|
|
82
85
|
return (
|
|
@@ -88,16 +91,20 @@ export const Button = forwardRef<any, ButtonProps>(function Button(
|
|
|
88
91
|
accessibilityState={{ disabled }}
|
|
89
92
|
disabled={disabled}
|
|
90
93
|
onPress={disabled ? undefined : onPress}
|
|
94
|
+
onPressIn={() => setHeld(true)}
|
|
95
|
+
onPressOut={() => setHeld(false)}
|
|
91
96
|
style={({ pressed }: { pressed: boolean }) => ({ opacity: pressed && !disabled ? 0.85 : 1 })}
|
|
92
97
|
{...props}
|
|
93
98
|
>
|
|
94
99
|
<Glass
|
|
95
100
|
effect={variant === "ghost" ? "none" : "regular"}
|
|
101
|
+
surface="control"
|
|
102
|
+
pressed={held && !disabled}
|
|
96
103
|
interactive={!disabled}
|
|
97
104
|
isDark={isDark}
|
|
98
105
|
style={buttonStyle}
|
|
99
106
|
>
|
|
100
|
-
{icon ? <View style={{ marginRight: children ?
|
|
107
|
+
{icon ? <View style={{ marginRight: children ? 7 : 0 }}>{icon}</View> : null}
|
|
101
108
|
{typeof children === "string" ? (
|
|
102
109
|
// A string label is text: it needs Text to inherit font and colour.
|
|
103
110
|
<Text style={textStyle} numberOfLines={1}>
|
package/src/Card.tsx
CHANGED
|
@@ -26,10 +26,10 @@ export const Card = forwardRef<any, CardProps>(function Card(
|
|
|
26
26
|
const isDark = useIsDark(isDarkProp);
|
|
27
27
|
|
|
28
28
|
const cardStyle: ViewStyle = {
|
|
29
|
-
padding:
|
|
29
|
+
padding: 24,
|
|
30
30
|
borderRadius: radii.lg,
|
|
31
31
|
flexDirection: "column",
|
|
32
|
-
gap:
|
|
32
|
+
gap: 16,
|
|
33
33
|
...(style as ViewStyle),
|
|
34
34
|
};
|
|
35
35
|
|
package/src/Dialog.tsx
CHANGED
|
@@ -103,14 +103,17 @@ export function Dialog({
|
|
|
103
103
|
>
|
|
104
104
|
<Glass
|
|
105
105
|
effect="regular"
|
|
106
|
+
surface="overlay"
|
|
106
107
|
isDark={isDark}
|
|
107
108
|
testID={testID}
|
|
108
109
|
style={{
|
|
109
|
-
borderRadius: radii.
|
|
110
|
-
borderWidth: 1,
|
|
111
|
-
borderColor: theme.edge,
|
|
110
|
+
borderRadius: radii.xl,
|
|
112
111
|
padding: 20,
|
|
113
112
|
gap: 8,
|
|
113
|
+
// The web overlay shadow: the panel has to float above the scrim.
|
|
114
|
+
shadowOpacity: 0.12,
|
|
115
|
+
shadowRadius: 50,
|
|
116
|
+
shadowOffset: { width: 0, height: 20 },
|
|
114
117
|
...(style as ViewStyle),
|
|
115
118
|
}}
|
|
116
119
|
>
|
|
@@ -124,7 +127,7 @@ export function Dialog({
|
|
|
124
127
|
)}
|
|
125
128
|
|
|
126
129
|
{description && (
|
|
127
|
-
<Text style={{ fontSize:
|
|
130
|
+
<Text style={{ fontSize: 14, color: theme.muted, lineHeight: 20 }}>{description}</Text>
|
|
128
131
|
)}
|
|
129
132
|
|
|
130
133
|
{children}
|
|
@@ -313,12 +316,16 @@ export function ActionSheet({
|
|
|
313
316
|
onPress={() => {}}
|
|
314
317
|
style={{ padding: 10, gap: 8 }}
|
|
315
318
|
>
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
319
|
+
{/* The web's ActionSheet is not one panel: it is a stack of separate
|
|
320
|
+
glass pills. That shape is the single most visible difference in
|
|
321
|
+
the owner's screenshots, so each row gets its own surface. */}
|
|
322
|
+
{(title || message) && (
|
|
323
|
+
<Glass
|
|
324
|
+
effect="regular"
|
|
325
|
+
surface="overlay"
|
|
326
|
+
isDark={isDark}
|
|
327
|
+
style={{ borderRadius: radii.lg }}
|
|
328
|
+
>
|
|
322
329
|
<View style={{ paddingVertical: 12, paddingHorizontal: 16, alignItems: "center" }}>
|
|
323
330
|
{title && (
|
|
324
331
|
<Text style={{ fontSize: 13, fontWeight: "600", color: theme.foreground }}>
|
|
@@ -331,44 +338,48 @@ export function ActionSheet({
|
|
|
331
338
|
</Text>
|
|
332
339
|
)}
|
|
333
340
|
</View>
|
|
334
|
-
|
|
341
|
+
</Glass>
|
|
342
|
+
)}
|
|
335
343
|
|
|
336
|
-
|
|
344
|
+
{options.map((option) => (
|
|
345
|
+
<Glass
|
|
346
|
+
key={option.label}
|
|
347
|
+
effect="regular"
|
|
348
|
+
surface="overlay"
|
|
349
|
+
isDark={isDark}
|
|
350
|
+
style={{ borderRadius: radii.pill }}
|
|
351
|
+
>
|
|
337
352
|
<Pressable
|
|
338
|
-
key={option.label}
|
|
339
353
|
accessibilityRole="button"
|
|
340
354
|
accessibilityLabel={option.label}
|
|
341
355
|
onPress={() => {
|
|
342
356
|
option.onPress?.();
|
|
343
357
|
close();
|
|
344
358
|
}}
|
|
345
|
-
style={{
|
|
346
|
-
paddingVertical: 14,
|
|
347
|
-
alignItems: "center",
|
|
348
|
-
borderTopWidth: index === 0 && !title && !message ? 0 : 1,
|
|
349
|
-
borderTopColor: theme.edge,
|
|
350
|
-
}}
|
|
359
|
+
style={{ minHeight: 44, paddingVertical: 12, paddingHorizontal: 20, alignItems: "center", justifyContent: "center" }}
|
|
351
360
|
>
|
|
352
361
|
<Text
|
|
353
362
|
style={{
|
|
354
|
-
fontSize:
|
|
355
|
-
|
|
363
|
+
fontSize: 17,
|
|
364
|
+
// The web's iOS-style action sheet: every row is the tint
|
|
365
|
+
// colour, and only a destructive one is red.
|
|
366
|
+
color: option.destructive ? theme.destructive : theme.fill,
|
|
356
367
|
}}
|
|
357
368
|
>
|
|
358
369
|
{option.label}
|
|
359
370
|
</Text>
|
|
360
371
|
</Pressable>
|
|
361
|
-
|
|
362
|
-
|
|
372
|
+
</Glass>
|
|
373
|
+
))}
|
|
363
374
|
|
|
364
|
-
<Glass effect="regular" isDark={isDark} style={{ borderRadius: radii.
|
|
375
|
+
<Glass effect="regular" surface="overlay" isDark={isDark} style={{ borderRadius: radii.pill }}>
|
|
365
376
|
<Pressable
|
|
366
377
|
accessibilityRole="button"
|
|
367
378
|
accessibilityLabel={cancelLabel}
|
|
368
379
|
onPress={close}
|
|
369
|
-
style={{ paddingVertical:
|
|
380
|
+
style={{ minHeight: 44, paddingVertical: 12, alignItems: "center", justifyContent: "center" }}
|
|
370
381
|
>
|
|
371
|
-
<Text style={{ fontSize:
|
|
382
|
+
<Text style={{ fontSize: 17, fontWeight: "600", color: theme.foreground }}>
|
|
372
383
|
{cancelLabel}
|
|
373
384
|
</Text>
|
|
374
385
|
</Pressable>
|