MCPcopy Create free account
hub / github.com/Effect-TS/effect / screen

Function screen

packages/ui/native/src/kit/StackTransition.ts:177–227  ·  view source on GitHub ↗
(
      entry: RouterStack.Entry<unknown>,
      index: number,
      gone: boolean
    )

Source from the content-addressed store, hash-verified

175 const moving = !model.settled || fresh || leaving.length > 0
176 const name = (entry: RouterStack.Entry<unknown> | undefined) => h.id(String(model.scope), entry?.id ?? "none")
177 const screen = (
178 entry: RouterStack.Entry<unknown>,
179 index: number,
180 gone: boolean
181 ) => {
182 const x = gone ? width : index === top ? 0 : under * width
183 const shown = gone || index === top || (index === top - 1 && moving)
184 const element = pipe(
185 h.view.key(String(entry.id)).style(fill),
186 Animation.named(name(entry)),
187 // A top screen that mounts after the stack is measured was pushed.
188 Animation.style({ transform: [{ translateX: x }] }, transition, {
189 transform: [{ translateX: width }]
190 }),
191 Animation.style({ opacity: shown ? 1 : 0 }, Animation.immediate)
192 )
193 .on("animationEnd", Message.Ended({ id: entry.id }))
194 .children(
195 Screen(h, {
196 key: String(entry.id),
197 props: {
198 entry,
199 index,
200 covered: gone || index !== top,
201 fade: false,
202 depth: 2,
203 draw
204 }
205 })
206 )
207 if (swipe === undefined || gone || index !== top || top === 0) {
208 return element
209 }
210 const below = name(entries[top - 1])
211 const self = name(entry)
212 return swipe.attach(h, element, {
213 width,
214 ready: !moving,
215 started: Message.Started(),
216 key: self,
217 move: (x, settle) => {
218 const then = settle ? transition : undefined
219 Animation.set(self, { transform: [{ translateX: x }] }, then)
220 Animation.set(
221 below,
222 { transform: [{ translateX: under * (width - x) }] },
223 then
224 )
225 }
226 })
227 }
228 const drawn = [
229 ...entries.map((entry, index) => screen(entry, index, false)),
230 ...leaving.map((entry) => screen(entry, top + 1, true))

Callers 1

StackTransition.tsFile · 0.85

Calls 10

ScreenInterface · 0.90
nameFunction · 0.70
onMethod · 0.65
styleMethod · 0.65
keyMethod · 0.65
setMethod · 0.65
pipeFunction · 0.50
StringFunction · 0.50
childrenMethod · 0.45
attachMethod · 0.45

Tested by

no test coverage detected