@stackflow/plugin-basic-ui 1.3.4-alpha.0 → 1.3.4-alpha.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.
@@ -36,8 +36,7 @@ export type AppScreenProps = Partial<
36
36
  "theme" | "modalPresentationStyle" | "ref" | "key"
37
37
  >;
38
38
  preventSwipeBack?: boolean;
39
- CUPERTINO_ONLY_modalPresentationStyle?: "fullScreen";
40
- ANDROID_ONLY_activityEnterStyle?: "slideInLeft";
39
+ modalPresentationStyle?: "fullScreen";
41
40
  children: React.ReactNode;
42
41
  };
43
42
  const AppScreen: React.FC<AppScreenProps> = ({
@@ -45,8 +44,7 @@ const AppScreen: React.FC<AppScreenProps> = ({
45
44
  dimBackgroundColor,
46
45
  appBar,
47
46
  preventSwipeBack,
48
- CUPERTINO_ONLY_modalPresentationStyle,
49
- ANDROID_ONLY_activityEnterStyle,
47
+ modalPresentationStyle,
50
48
  children,
51
49
  }) => {
52
50
  const globalOptions = useGlobalOptions();
@@ -60,78 +58,44 @@ const AppScreen: React.FC<AppScreenProps> = ({
60
58
  const edgeRef = useRef<HTMLDivElement>(null);
61
59
  const appBarRef = useRef<HTMLDivElement>(null);
62
60
 
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);
61
+ const presentModalFullScreen = modalPresentationStyle === "fullScreen";
62
+ const swipeBackPrevented = preventSwipeBack || presentModalFullScreen;
108
63
 
109
64
  useStyleEffectHide({
110
65
  refs: [appScreenRef],
111
66
  hasEffect: true,
112
67
  });
113
68
  useStyleEffectOffset({
114
- refs:
115
- globalOptions.theme === "cupertino" ||
116
- activityEnterStyle === "slideInLeft"
117
- ? [paperRef]
118
- : [paperRef, appBarRef],
119
69
  theme: globalOptions.theme,
120
- activityEnterStyle,
121
- hasEffect: modalPresentationStyle !== "fullScreen",
70
+ refs:
71
+ globalOptions.theme === "cupertino" ? [paperRef] : [paperRef, appBarRef],
72
+ hasEffect: !presentModalFullScreen,
122
73
  });
123
74
  useStyleEffectSwipeBack({
75
+ theme: globalOptions.theme,
124
76
  dimRef,
125
77
  edgeRef,
126
78
  paperRef,
127
- theme: globalOptions.theme,
79
+ hasEffect: true,
128
80
  prevented: swipeBackPrevented,
129
81
  onSwiped() {
130
82
  pop();
131
83
  },
132
- hasEffect: true,
133
84
  });
134
85
 
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
+
135
99
  const onAppBarTopClick: React.MouseEventHandler = (e) => {
136
100
  appBar?.onTopClick?.(e);
137
101
 
@@ -184,15 +148,12 @@ const AppScreen: React.FC<AppScreenProps> = ({
184
148
  }),
185
149
  )}
186
150
  >
187
- {activityEnterStyle !== "slideInLeft" && (
188
- <div className={css.dim} ref={dimRef} />
189
- )}
151
+ <div className={css.dim} ref={dimRef} />
190
152
  {appBar && (
191
153
  <AppBar
192
154
  {...appBar}
193
155
  ref={appBarRef}
194
156
  modalPresentationStyle={modalPresentationStyle}
195
- activityEnterStyle={activityEnterStyle}
196
157
  onTopClick={onAppBarTopClick}
197
158
  />
198
159
  )}
@@ -200,8 +161,7 @@ const AppScreen: React.FC<AppScreenProps> = ({
200
161
  key={activity?.id}
201
162
  className={css.paper({
202
163
  hasAppBar,
203
- modalPresentationStyle,
204
- activityEnterStyle,
164
+ presentModalFullScreen,
205
165
  })}
206
166
  ref={paperRef}
207
167
  >
@@ -10,12 +10,10 @@ export const OFFSET_PX_CUPERTINO = 80;
10
10
  export function useStyleEffectOffset({
11
11
  refs,
12
12
  theme,
13
- activityEnterStyle,
14
13
  hasEffect,
15
14
  }: {
16
15
  refs: Array<React.RefObject<any>>;
17
16
  theme: "android" | "cupertino";
18
- activityEnterStyle?: "slideInLeft";
19
17
  hasEffect?: boolean;
20
18
  }) {
21
19
  useStyleEffect({
@@ -23,25 +21,10 @@ export function useStyleEffectOffset({
23
21
  refs,
24
22
  effect: hasEffect
25
23
  ? ({ activityTransitionState, refs }) => {
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
- }
24
+ const transform =
25
+ theme === "cupertino"
26
+ ? `translate3d(-${OFFSET_PX_CUPERTINO / 16}rem, 0, 0)`
27
+ : `translate3d(0, -${OFFSET_PX_ANDROID / 16}rem, 0)`;
45
28
 
46
29
  const cleanup = () => {
47
30
  requestNextFrame(() => {
@@ -53,7 +36,6 @@ export function useStyleEffectOffset({
53
36
  const $el = ref.current;
54
37
 
55
38
  $el.style.transform = "";
56
- $el.style.opacity = "";
57
39
 
58
40
  listenOnce($el, "transitionend", () => {
59
41
  $el.style.transition = "";
@@ -73,7 +55,6 @@ export function useStyleEffectOffset({
73
55
  ref.current.style.transition =
74
56
  globalVars.computedTransitionDuration;
75
57
  ref.current.style.transform = transform;
76
- ref.current.style.opacity = opacity;
77
58
  });
78
59
 
79
60
  switch (activityTransitionState) {