tweak rendering
This commit is contained in:
@@ -33,6 +33,8 @@ const Context = React.createContext<Context>({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const useScreenHider = () => React.useContext(Context)
|
||||||
|
|
||||||
export function Outer({
|
export function Outer({
|
||||||
modui,
|
modui,
|
||||||
children,
|
children,
|
||||||
@@ -44,40 +46,33 @@ export function Outer({
|
|||||||
const [isContentVisible, setIsContentVisible] = React.useState(!blur)
|
const [isContentVisible, setIsContentVisible] = React.useState(!blur)
|
||||||
const info = useModerationCauseDescription(blur)
|
const info = useModerationCauseDescription(blur)
|
||||||
|
|
||||||
const meta = React.useMemo(
|
const meta = {
|
||||||
() => ({
|
isNoPwi: Boolean(
|
||||||
isNoPwi: !!modui.blurs.find(
|
modui.blurs.find(
|
||||||
cause =>
|
cause =>
|
||||||
cause.type === 'label' &&
|
cause.type === 'label' &&
|
||||||
cause.labelDef.identifier === '!no-unauthenticated',
|
cause.labelDef.identifier === '!no-unauthenticated',
|
||||||
),
|
),
|
||||||
noOverride: modui.noOverride,
|
),
|
||||||
}),
|
noOverride: modui.noOverride,
|
||||||
[modui],
|
}
|
||||||
)
|
|
||||||
|
|
||||||
const showInfoDialog = React.useCallback(() => {
|
const showInfoDialog = () => {
|
||||||
control.open()
|
control.open()
|
||||||
}, [control])
|
}
|
||||||
|
|
||||||
const onSetContentVisible = React.useCallback(
|
const onSetContentVisible = (show: boolean) => {
|
||||||
(show: boolean) => {
|
if (meta.noOverride) return
|
||||||
if (meta.noOverride) return
|
setIsContentVisible(show)
|
||||||
setIsContentVisible(show)
|
}
|
||||||
},
|
|
||||||
[setIsContentVisible, meta],
|
|
||||||
)
|
|
||||||
|
|
||||||
const ctx = React.useMemo(
|
const ctx = {
|
||||||
() => ({
|
isContentVisible,
|
||||||
isContentVisible,
|
setIsContentVisible: onSetContentVisible,
|
||||||
setIsContentVisible: onSetContentVisible,
|
showInfoDialog,
|
||||||
showInfoDialog,
|
info,
|
||||||
info,
|
meta,
|
||||||
meta,
|
}
|
||||||
}),
|
|
||||||
[isContentVisible, onSetContentVisible, info, meta, showInfoDialog],
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Context.Provider value={ctx}>
|
<Context.Provider value={ctx}>
|
||||||
@@ -87,22 +82,12 @@ export function Outer({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Content({
|
export function Content({children}: {children: React.ReactNode}) {
|
||||||
children,
|
const ctx = useScreenHider()
|
||||||
}: {
|
return ctx.isContentVisible ? children : null
|
||||||
children: (context: Context) => React.ReactNode
|
|
||||||
}) {
|
|
||||||
const ctx = React.useContext(Context)
|
|
||||||
const child = React.useMemo(() => children(ctx), [ctx, children])
|
|
||||||
return ctx.isContentVisible ? child : null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Mask({
|
export function Mask({children}: {children: React.ReactNode}) {
|
||||||
children,
|
const ctx = useScreenHider()
|
||||||
}: {
|
return ctx.isContentVisible ? null : children
|
||||||
children: (context: Context) => React.ReactNode
|
|
||||||
}) {
|
|
||||||
const ctx = React.useContext(Context)
|
|
||||||
const child = React.useMemo(() => children(ctx), [ctx, children])
|
|
||||||
return !ctx.isContentVisible ? child : null
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,71 +193,29 @@ function ProfileListScreenLoaded({
|
|||||||
return (
|
return (
|
||||||
<Hider.Outer modui={moderation.ui('contentView')}>
|
<Hider.Outer modui={moderation.ui('contentView')}>
|
||||||
<Hider.Mask>
|
<Hider.Mask>
|
||||||
{() => <ListHiddenScreen list={list} preferences={preferences} />}
|
<ListHiddenScreen list={list} preferences={preferences} />
|
||||||
</Hider.Mask>
|
</Hider.Mask>
|
||||||
<Hider.Content>
|
<Hider.Content>
|
||||||
{() => (
|
|
||||||
<View style={s.hContentRegion}>
|
|
||||||
<PagerWithHeader
|
|
||||||
items={SECTION_TITLES_CURATE}
|
|
||||||
isHeaderReady={true}
|
|
||||||
renderHeader={renderHeader}
|
|
||||||
onCurrentPageSelected={onCurrentPageSelected}>
|
|
||||||
{({headerHeight, scrollElRef, isFocused}) => (
|
|
||||||
<FeedSection
|
|
||||||
ref={feedSectionRef}
|
|
||||||
feed={`list|${uri}`}
|
|
||||||
scrollElRef={scrollElRef as ListRef}
|
|
||||||
headerHeight={headerHeight}
|
|
||||||
isFocused={isScreenFocused && isFocused}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{({headerHeight, scrollElRef}) => (
|
|
||||||
<AboutSection
|
|
||||||
ref={aboutSectionRef}
|
|
||||||
scrollElRef={scrollElRef as ListRef}
|
|
||||||
list={list}
|
|
||||||
onPressAddUser={onPressAddUser}
|
|
||||||
headerHeight={headerHeight}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</PagerWithHeader>
|
|
||||||
<FAB
|
|
||||||
testID="composeFAB"
|
|
||||||
onPress={() => openComposer({})}
|
|
||||||
icon={
|
|
||||||
<ComposeIcon2
|
|
||||||
strokeWidth={1.5}
|
|
||||||
size={29}
|
|
||||||
style={{color: 'white'}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
accessibilityRole="button"
|
|
||||||
accessibilityLabel={_(msg`New post`)}
|
|
||||||
accessibilityHint=""
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
</Hider.Content>
|
|
||||||
</Hider.Outer>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<Hider.Outer modui={moderation.ui('contentView')}>
|
|
||||||
<Hider.Mask>
|
|
||||||
{() => <ListHiddenScreen list={list} preferences={preferences} />}
|
|
||||||
</Hider.Mask>
|
|
||||||
<Hider.Content>
|
|
||||||
{() => (
|
|
||||||
<View style={s.hContentRegion}>
|
<View style={s.hContentRegion}>
|
||||||
<PagerWithHeader
|
<PagerWithHeader
|
||||||
items={SECTION_TITLES_MOD}
|
items={SECTION_TITLES_CURATE}
|
||||||
isHeaderReady={true}
|
isHeaderReady={true}
|
||||||
renderHeader={renderHeader}>
|
renderHeader={renderHeader}
|
||||||
|
onCurrentPageSelected={onCurrentPageSelected}>
|
||||||
|
{({headerHeight, scrollElRef, isFocused}) => (
|
||||||
|
<FeedSection
|
||||||
|
ref={feedSectionRef}
|
||||||
|
feed={`list|${uri}`}
|
||||||
|
scrollElRef={scrollElRef as ListRef}
|
||||||
|
headerHeight={headerHeight}
|
||||||
|
isFocused={isScreenFocused && isFocused}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{({headerHeight, scrollElRef}) => (
|
{({headerHeight, scrollElRef}) => (
|
||||||
<AboutSection
|
<AboutSection
|
||||||
list={list}
|
ref={aboutSectionRef}
|
||||||
scrollElRef={scrollElRef as ListRef}
|
scrollElRef={scrollElRef as ListRef}
|
||||||
|
list={list}
|
||||||
onPressAddUser={onPressAddUser}
|
onPressAddUser={onPressAddUser}
|
||||||
headerHeight={headerHeight}
|
headerHeight={headerHeight}
|
||||||
/>
|
/>
|
||||||
@@ -278,7 +236,45 @@ function ProfileListScreenLoaded({
|
|||||||
accessibilityHint=""
|
accessibilityHint=""
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
)}
|
</Hider.Content>
|
||||||
|
</Hider.Outer>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Hider.Outer modui={moderation.ui('contentView')}>
|
||||||
|
<Hider.Mask>
|
||||||
|
<ListHiddenScreen list={list} preferences={preferences} />
|
||||||
|
</Hider.Mask>
|
||||||
|
<Hider.Content>
|
||||||
|
<View style={s.hContentRegion}>
|
||||||
|
<PagerWithHeader
|
||||||
|
items={SECTION_TITLES_MOD}
|
||||||
|
isHeaderReady={true}
|
||||||
|
renderHeader={renderHeader}>
|
||||||
|
{({headerHeight, scrollElRef}) => (
|
||||||
|
<AboutSection
|
||||||
|
list={list}
|
||||||
|
scrollElRef={scrollElRef as ListRef}
|
||||||
|
onPressAddUser={onPressAddUser}
|
||||||
|
headerHeight={headerHeight}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</PagerWithHeader>
|
||||||
|
<FAB
|
||||||
|
testID="composeFAB"
|
||||||
|
onPress={() => openComposer({})}
|
||||||
|
icon={
|
||||||
|
<ComposeIcon2
|
||||||
|
strokeWidth={1.5}
|
||||||
|
size={29}
|
||||||
|
style={{color: 'white'}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
accessibilityRole="button"
|
||||||
|
accessibilityLabel={_(msg`New post`)}
|
||||||
|
accessibilityHint=""
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
</Hider.Content>
|
</Hider.Content>
|
||||||
</Hider.Outer>
|
</Hider.Outer>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user