@stackflow/plugin-basic-ui 1.3.3-alpha.0 → 1.3.4-alpha.0

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.
@@ -125,17 +125,17 @@ export const paper = recipe({
125
125
  paddingTop: globalVars.appBar.height,
126
126
  "@supports": {
127
127
  "(padding-top: constant(safe-area-inset-top))": {
128
- paddingTop: `calc(${globalVars.appBar.height} + max(${globalVars.appBar.forceSafeAreaInsetTop}, constant(safe-area-inset-top)))`,
128
+ paddingTop: `calc(${globalVars.appBar.height} + max(${globalVars.appBar.minSafeAreaInsetTop}, constant(safe-area-inset-top)))`,
129
129
  },
130
130
  "(padding-top: env(safe-area-inset-top))": {
131
- paddingTop: `calc(${globalVars.appBar.height} + max(${globalVars.appBar.forceSafeAreaInsetTop}, env(safe-area-inset-top)))`,
131
+ paddingTop: `calc(${globalVars.appBar.height} + max(${globalVars.appBar.minSafeAreaInsetTop}, env(safe-area-inset-top)))`,
132
132
  },
133
133
  },
134
134
  },
135
135
  ],
136
136
  },
137
- presentModalFullScreen: {
138
- true: {
137
+ modalPresentationStyle: {
138
+ fullScreen: {
139
139
  selectors: {
140
140
  [`${cupertino} &`]: {
141
141
  transform: "translate3d(0, 100%, 0)",
@@ -143,6 +143,15 @@ export const paper = recipe({
143
143
  },
144
144
  },
145
145
  },
146
+ activityEnterStyle: {
147
+ slideInLeft: {
148
+ selectors: {
149
+ [`${android} &`]: {
150
+ transform: "translate3d(50%, 0, 0)",
151
+ },
152
+ },
153
+ },
154
+ },
146
155
  },
147
156
  });
148
157
 
@@ -36,7 +36,8 @@ export type AppScreenProps = Partial<
36
36
  "theme" | "modalPresentationStyle" | "ref" | "key"
37
37
  >;
38
38
  preventSwipeBack?: boolean;
39
- modalPresentationStyle?: "fullScreen";
39
+ CUPERTINO_ONLY_modalPresentationStyle?: "fullScreen";
40
+ ANDROID_ONLY_activityEnterStyle?: "slideInLeft";
40
41
  children: React.ReactNode;
41
42
  };
42
43
  const AppScreen: React.FC<AppScreenProps> = ({
@@ -44,7 +45,8 @@ const AppScreen: React.FC<AppScreenProps> = ({
44
45
  dimBackgroundColor,
45
46
  appBar,
46
47
  preventSwipeBack,
47
- modalPresentationStyle,
48
+ CUPERTINO_ONLY_modalPresentationStyle,
49
+ ANDROID_ONLY_activityEnterStyle,
48
50
  children,
49
51
  }) => {
50
52
  const globalOptions = useGlobalOptions();
@@ -58,44 +60,78 @@ const AppScreen: React.FC<AppScreenProps> = ({
58
60
  const edgeRef = useRef<HTMLDivElement>(null);
59
61
  const appBarRef = useRef<HTMLDivElement>(null);
60
62
 
61
- const presentModalFullScreen = modalPresentationStyle === "fullScreen";
62
- const swipeBackPrevented = preventSwipeBack || presentModalFullScreen;
63
+ const modalPresentationStyle =
64
+ globalOptions.theme === "cupertino"
65
+ ? CUPERTINO_ONLY_modalPresentationStyle
66
+ : undefined;
67
+ const activityEnterStyle =
68
+ globalOptions.theme === "android"
69
+ ? ANDROID_ONLY_activityEnterStyle
70
+ : undefined;
71
+
72
+ const swipeBackPrevented =
73
+ preventSwipeBack || modalPresentationStyle === "fullScreen";
74
+
75
+ const hasAppBar = !!appBar;
76
+
77
+ const zIndexBase = (activity?.zIndex ?? 0) * 5;
78
+
79
+ let zIndexDim: number;
80
+ let zIndexPaper: number;
81
+ let zIndexEdge: number;
82
+ let zIndexAppBar: number;
83
+
84
+ switch (globalOptions.theme) {
85
+ case "cupertino": {
86
+ zIndexDim =
87
+ zIndexBase + (modalPresentationStyle === "fullScreen" ? 2 : 0);
88
+ zIndexPaper =
89
+ zIndexBase +
90
+ (hasAppBar && modalPresentationStyle !== "fullScreen" ? 1 : 3);
91
+ zIndexEdge = zIndexBase + 4;
92
+ zIndexAppBar = zIndexBase + 7;
93
+ break;
94
+ }
95
+ case "android":
96
+ default: {
97
+ zIndexDim = zIndexBase;
98
+ zIndexPaper = zIndexBase + (activityEnterStyle === "slideInLeft" ? 1 : 3);
99
+ zIndexEdge = zIndexBase + 4;
100
+ zIndexAppBar =
101
+ zIndexBase + (activityEnterStyle === "slideInLeft" ? 7 : 4);
102
+ break;
103
+ }
104
+ }
105
+
106
+ const transitionState = activity?.transitionState ?? "enter-done";
107
+ const lazyTransitionState = useLazy(transitionState);
63
108
 
64
109
  useStyleEffectHide({
65
110
  refs: [appScreenRef],
66
111
  hasEffect: true,
67
112
  });
68
113
  useStyleEffectOffset({
69
- theme: globalOptions.theme,
70
114
  refs:
71
- globalOptions.theme === "cupertino" ? [paperRef] : [paperRef, appBarRef],
72
- hasEffect: !presentModalFullScreen,
115
+ globalOptions.theme === "cupertino" ||
116
+ activityEnterStyle === "slideInLeft"
117
+ ? [paperRef]
118
+ : [paperRef, appBarRef],
119
+ theme: globalOptions.theme,
120
+ activityEnterStyle,
121
+ hasEffect: modalPresentationStyle !== "fullScreen",
73
122
  });
74
123
  useStyleEffectSwipeBack({
75
- theme: globalOptions.theme,
76
124
  dimRef,
77
125
  edgeRef,
78
126
  paperRef,
79
- hasEffect: true,
127
+ theme: globalOptions.theme,
80
128
  prevented: swipeBackPrevented,
81
129
  onSwiped() {
82
130
  pop();
83
131
  },
132
+ hasEffect: true,
84
133
  });
85
134
 
86
- const hasAppBar = !!appBar;
87
-
88
- const zIndexBase = (activity?.zIndex ?? 0) * 5;
89
- const zIndexDim = zIndexBase;
90
- const zIndexPaper =
91
- zIndexBase + (globalOptions.theme === "cupertino" && hasAppBar ? 1 : 3);
92
- const zIndexEdge = zIndexBase + 4;
93
- const zIndexAppBar =
94
- globalOptions.theme === "cupertino" ? zIndexBase + 7 : zIndexBase + 4;
95
-
96
- const transitionState = activity?.transitionState ?? "enter-done";
97
- const lazyTransitionState = useLazy(transitionState);
98
-
99
135
  const onAppBarTopClick: React.MouseEventHandler = (e) => {
100
136
  appBar?.onTopClick?.(e);
101
137
 
@@ -148,12 +184,15 @@ const AppScreen: React.FC<AppScreenProps> = ({
148
184
  }),
149
185
  )}
150
186
  >
151
- <div className={css.dim} ref={dimRef} />
187
+ {activityEnterStyle !== "slideInLeft" && (
188
+ <div className={css.dim} ref={dimRef} />
189
+ )}
152
190
  {appBar && (
153
191
  <AppBar
154
192
  {...appBar}
155
193
  ref={appBarRef}
156
194
  modalPresentationStyle={modalPresentationStyle}
195
+ activityEnterStyle={activityEnterStyle}
157
196
  onTopClick={onAppBarTopClick}
158
197
  />
159
198
  )}
@@ -161,7 +200,8 @@ const AppScreen: React.FC<AppScreenProps> = ({
161
200
  key={activity?.id}
162
201
  className={css.paper({
163
202
  hasAppBar,
164
- presentModalFullScreen,
203
+ modalPresentationStyle,
204
+ activityEnterStyle,
165
205
  })}
166
206
  ref={paperRef}
167
207
  >
@@ -10,10 +10,12 @@ export const OFFSET_PX_CUPERTINO = 80;
10
10
  export function useStyleEffectOffset({
11
11
  refs,
12
12
  theme,
13
+ activityEnterStyle,
13
14
  hasEffect,
14
15
  }: {
15
16
  refs: Array<React.RefObject<any>>;
16
17
  theme: "android" | "cupertino";
18
+ activityEnterStyle?: "slideInLeft";
17
19
  hasEffect?: boolean;
18
20
  }) {
19
21
  useStyleEffect({
@@ -21,10 +23,25 @@ export function useStyleEffectOffset({
21
23
  refs,
22
24
  effect: hasEffect
23
25
  ? ({ activityTransitionState, refs }) => {
24
- const transform =
25
- theme === "cupertino"
26
- ? `translate3d(-${OFFSET_PX_CUPERTINO / 16}rem, 0, 0)`
27
- : `translate3d(0, -${OFFSET_PX_ANDROID / 16}rem, 0)`;
26
+ let transform: string;
27
+ let opacity: string;
28
+
29
+ switch (theme) {
30
+ case "cupertino": {
31
+ transform = `translate3d(-${OFFSET_PX_CUPERTINO / 16}rem, 0, 0)`;
32
+ opacity = "1";
33
+ break;
34
+ }
35
+ case "android":
36
+ default: {
37
+ transform =
38
+ activityEnterStyle === "slideInLeft"
39
+ ? `translate3d(-50%, 0, 0)`
40
+ : `translate3d(0, -${OFFSET_PX_ANDROID / 16}rem, 0)`;
41
+ opacity = activityEnterStyle === "slideInLeft" ? "0" : "1";
42
+ break;
43
+ }
44
+ }
28
45
 
29
46
  const cleanup = () => {
30
47
  requestNextFrame(() => {
@@ -36,6 +53,7 @@ export function useStyleEffectOffset({
36
53
  const $el = ref.current;
37
54
 
38
55
  $el.style.transform = "";
56
+ $el.style.opacity = "";
39
57
 
40
58
  listenOnce($el, "transitionend", () => {
41
59
  $el.style.transition = "";
@@ -55,6 +73,7 @@ export function useStyleEffectOffset({
55
73
  ref.current.style.transition =
56
74
  globalVars.computedTransitionDuration;
57
75
  ref.current.style.transform = transform;
76
+ ref.current.style.opacity = opacity;
58
77
  });
59
78
 
60
79
  switch (activityTransitionState) {