fix(mobile): profile modal header style
Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -39,7 +39,7 @@ class FOWebView: WKWebView {
|
||||
navigationDelegate = self
|
||||
uiDelegate = self
|
||||
}
|
||||
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
@@ -6,13 +6,10 @@ import WebKit
|
||||
|
||||
class WebViewView: ExpoView {
|
||||
private var cancellable: AnyCancellable?
|
||||
private let rctView = RCTView(frame: .zero)
|
||||
|
||||
required init(appContext: AppContext? = nil) {
|
||||
super.init(appContext: appContext)
|
||||
addSubview(rctView)
|
||||
|
||||
rctView.addSubview(SharedWebViewModule.sharedWebView!)
|
||||
addSubview(SharedWebViewModule.sharedWebView!)
|
||||
|
||||
clipsToBounds = true
|
||||
cancellable = WebViewManager.state.$contentHeight
|
||||
@@ -21,7 +18,7 @@ class WebViewView: ExpoView {
|
||||
self?.layoutSubviews()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
deinit {
|
||||
cancellable?.cancel()
|
||||
}
|
||||
@@ -40,7 +37,6 @@ class WebViewView: ExpoView {
|
||||
webView.scrollView.frame = rect
|
||||
|
||||
frame = rect
|
||||
rctView.frame = rect
|
||||
onContentHeightChange(["height": Float(rect.height)])
|
||||
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ const TabBarBackground = () => {
|
||||
<ThemedBlurView style={styles.blurEffect} />
|
||||
</Animated.View>
|
||||
<Animated.View
|
||||
className="bg-opaque-separator absolute top-0 w-full"
|
||||
className="bg-system-fill absolute top-0 w-full"
|
||||
style={[
|
||||
separatorStyle,
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
} from "./constants"
|
||||
import { GroupedInsetListCardItemStyle } from "./GroupedInsetListCardItemStyle"
|
||||
|
||||
type GroupedInsetListCardProps = {
|
||||
interface GroupedInsetListCardProps {
|
||||
showSeparator?: boolean
|
||||
SeparatorComponent?: FC
|
||||
}
|
||||
@@ -66,7 +66,7 @@ export const GroupedInsetListCard: FC<
|
||||
<SeparatorComponent />
|
||||
) : (
|
||||
<View
|
||||
className={cn("bg-opaque-separator", isNavigationLink ? "ml-16" : "ml-4")}
|
||||
className={cn("bg-system-fill", isNavigationLink ? "ml-16" : "ml-4")}
|
||||
style={{ height: StyleSheet.hairlineWidth }}
|
||||
/>
|
||||
))}
|
||||
|
||||
@@ -114,7 +114,7 @@ const ListImpl: React.FC<{ id: string }> = ({ id }) => {
|
||||
const SeparatorComponent = () => {
|
||||
return (
|
||||
<View
|
||||
className="bg-opaque-separator ml-16"
|
||||
className="bg-system-fill ml-16"
|
||||
style={{ height: StyleSheet.hairlineWidth }}
|
||||
collapsable={false}
|
||||
/>
|
||||
|
||||
@@ -1,278 +0,0 @@
|
||||
import type { FeedViewType } from "@follow/constants"
|
||||
import { cn } from "@follow/utils"
|
||||
import { Fragment, useCallback, useEffect, useMemo } from "react"
|
||||
import {
|
||||
ActivityIndicator,
|
||||
FlatList,
|
||||
Image,
|
||||
Share,
|
||||
StyleSheet,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from "react-native"
|
||||
import Animated, { useAnimatedScrollHandler, useSharedValue } from "react-native-reanimated"
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context"
|
||||
|
||||
import { ReAnimatedScrollView } from "@/src/components/common/AnimatedComponents"
|
||||
import { BlurEffect } from "@/src/components/common/BlurEffect"
|
||||
import { FallbackIcon } from "@/src/components/ui/icon/fallback-icon"
|
||||
import type { FeedIconRequiredFeed } from "@/src/components/ui/icon/feed-icon"
|
||||
import { FeedIcon } from "@/src/components/ui/icon/feed-icon"
|
||||
import { MingcuteLeftLineIcon } from "@/src/icons/mingcute_left_line"
|
||||
import { Share3CuteReIcon } from "@/src/icons/share_3_cute_re"
|
||||
import type { apiClient } from "@/src/lib/api-fetch"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import type { FeedModel } from "@/src/store/feed/types"
|
||||
import type { ListModel } from "@/src/store/list/store"
|
||||
import { useWhoami } from "@/src/store/user/hooks"
|
||||
import { useColor } from "@/src/theme/colors"
|
||||
|
||||
import { ItemSeparator } from "../../subscription/ItemSeparator"
|
||||
import { useShareSubscription } from "../hooks/useShareSubscription"
|
||||
import { UserHeaderBanner } from "../UserHeaderBanner"
|
||||
|
||||
type Subscription = Awaited<ReturnType<typeof apiClient.subscriptions.$get>>["data"][number]
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export const ProfileScreen = () => {
|
||||
const scrollY = useSharedValue(0)
|
||||
const whoami = useWhoami()
|
||||
const {
|
||||
data: subscriptions,
|
||||
isLoading,
|
||||
isError,
|
||||
} = useShareSubscription({
|
||||
userId: whoami?.id!,
|
||||
})
|
||||
|
||||
const headerOpacity = useSharedValue(0)
|
||||
const scrollHandler = useAnimatedScrollHandler((event) => {
|
||||
scrollY.value = event.contentOffset.y
|
||||
headerOpacity.value = scrollY.value / 100
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (isError) {
|
||||
toast.error("Failed to fetch subscriptions")
|
||||
}
|
||||
}, [isError])
|
||||
|
||||
const insets = useSafeAreaInsets()
|
||||
|
||||
const textLabelColor = useColor("label")
|
||||
const openShareUrl = useCallback(() => {
|
||||
if (!whoami?.id) return
|
||||
Share.share({
|
||||
url: `https://app.follow.is/share/users/${whoami.id}`,
|
||||
title: `Folo | ${whoami.name}'s Profile`,
|
||||
})
|
||||
}, [whoami?.id, whoami?.name])
|
||||
|
||||
const navigation = useNavigation()
|
||||
return (
|
||||
<View className="bg-system-grouped-background flex-1">
|
||||
<ReAnimatedScrollView
|
||||
nestedScrollEnabled
|
||||
onScroll={scrollHandler}
|
||||
contentContainerStyle={{ paddingTop: insets.top, paddingBottom: insets.bottom }}
|
||||
>
|
||||
{!!whoami?.id && <UserHeaderBanner scrollY={scrollY} userId={whoami.id} />}
|
||||
|
||||
{isLoading && <ActivityIndicator className="mt-24" size={28} />}
|
||||
{!isLoading && subscriptions && <SubscriptionList subscriptions={subscriptions.data} />}
|
||||
</ReAnimatedScrollView>
|
||||
{/* Top transparent header buttons */}
|
||||
<TouchableOpacity
|
||||
onPress={() => navigation.back()}
|
||||
className="absolute left-4"
|
||||
style={{ top: insets.top }}
|
||||
>
|
||||
<MingcuteLeftLineIcon color="#fff" />
|
||||
</TouchableOpacity>
|
||||
|
||||
<TouchableOpacity
|
||||
onPress={openShareUrl}
|
||||
className="absolute right-4"
|
||||
style={{ top: insets.top }}
|
||||
>
|
||||
<Share3CuteReIcon color="#fff" />
|
||||
</TouchableOpacity>
|
||||
{/* Header */}
|
||||
<Animated.View
|
||||
pointerEvents="none"
|
||||
className="border-b-hairline border-opaque-separator pt-safe absolute inset-x-0 top-0 flex-row items-center px-4 pb-2"
|
||||
style={{ opacity: headerOpacity }}
|
||||
>
|
||||
<BlurEffect />
|
||||
<TouchableOpacity onPress={() => navigation.back()}>
|
||||
<MingcuteLeftLineIcon color={textLabelColor} />
|
||||
</TouchableOpacity>
|
||||
|
||||
<Text className="text-label flex-1 text-center text-lg font-medium">
|
||||
{whoami?.name}'s Profile
|
||||
</Text>
|
||||
|
||||
<TouchableOpacity onPress={openShareUrl}>
|
||||
<Share3CuteReIcon color={textLabelColor} />
|
||||
</TouchableOpacity>
|
||||
</Animated.View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
type PickedListModel = Pick<ListModel, "id" | "title" | "image" | "description" | "view"> & {
|
||||
customTitle?: string | null
|
||||
}
|
||||
type PickedFeedModel = Pick<
|
||||
FeedModel,
|
||||
"id" | "title" | "description" | "siteUrl" | "url" | "image"
|
||||
> & {
|
||||
customTitle?: string | null
|
||||
view: FeedViewType
|
||||
}
|
||||
const SubscriptionList = ({ subscriptions }: { subscriptions: Subscription[] }) => {
|
||||
const { lists, feeds, groupedFeeds } = useMemo(() => {
|
||||
const lists = [] as PickedListModel[]
|
||||
const feeds = [] as PickedFeedModel[]
|
||||
|
||||
const groupedFeeds = {} as Record<string, PickedFeedModel[]>
|
||||
|
||||
for (const subscription of subscriptions) {
|
||||
if ("listId" in subscription) {
|
||||
lists.push({
|
||||
id: subscription.listId,
|
||||
title: subscription.lists.title!,
|
||||
image: subscription.lists.image!,
|
||||
description: subscription.lists.description!,
|
||||
view: subscription.lists.view,
|
||||
customTitle: subscription.title,
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
if ("feedId" in subscription && "feeds" in subscription) {
|
||||
const feed = {
|
||||
id: subscription.feedId,
|
||||
title: subscription.feeds.title!,
|
||||
image: subscription.feeds.image!,
|
||||
description: subscription.feeds.description!,
|
||||
siteUrl: subscription.feeds.siteUrl!,
|
||||
url: subscription.feeds.url!,
|
||||
view: subscription.view as FeedViewType,
|
||||
customTitle: subscription.title,
|
||||
}
|
||||
|
||||
if (subscription.category) {
|
||||
groupedFeeds[subscription.category] = [
|
||||
...(groupedFeeds[subscription.category] || []),
|
||||
feed,
|
||||
]
|
||||
} else {
|
||||
feeds.push(feed)
|
||||
}
|
||||
}
|
||||
}
|
||||
return { lists, feeds, groupedFeeds }
|
||||
}, [subscriptions])
|
||||
|
||||
const hasFeeds = Object.keys(groupedFeeds).length > 0 || feeds.length > 0
|
||||
return (
|
||||
<View>
|
||||
{lists.length > 0 && (
|
||||
<Fragment>
|
||||
<SectionHeader title="Lists" />
|
||||
|
||||
<FlatList
|
||||
scrollEnabled={false}
|
||||
data={lists}
|
||||
renderItem={renderListItems}
|
||||
ItemSeparatorComponent={ItemSeparator}
|
||||
/>
|
||||
</Fragment>
|
||||
)}
|
||||
{hasFeeds && (
|
||||
<View className="mt-4">
|
||||
<SectionHeader title="Feeds" />
|
||||
{Object.entries(groupedFeeds).map(([category, feeds], index) => (
|
||||
<Fragment key={category}>
|
||||
<Text
|
||||
className={cn(
|
||||
"text-secondary-label mb-2 ml-3 text-sm font-medium",
|
||||
index !== 0 ? "mt-6" : "",
|
||||
)}
|
||||
>
|
||||
{category}
|
||||
</Text>
|
||||
<FlatList
|
||||
scrollEnabled={false}
|
||||
data={feeds}
|
||||
renderItem={renderFeedItems}
|
||||
ItemSeparatorComponent={ItemSeparator}
|
||||
/>
|
||||
</Fragment>
|
||||
))}
|
||||
|
||||
<Text className="text-secondary-label mb-2 ml-3 mt-6 text-sm font-medium">
|
||||
Uncategorized Feeds
|
||||
</Text>
|
||||
<FlatList
|
||||
scrollEnabled={false}
|
||||
data={feeds}
|
||||
renderItem={renderFeedItems}
|
||||
ItemSeparatorComponent={ItemSeparator}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
const renderListItems = ({ item }: { item: PickedListModel }) => (
|
||||
<View className="bg-secondary-system-grouped-background h-12 flex-row items-center px-3">
|
||||
<View className="overflow-hidden rounded">
|
||||
{!!item.image && (
|
||||
<Image source={{ uri: item.image, width: 24, height: 24 }} resizeMode="cover" />
|
||||
)}
|
||||
{!item.image && <FallbackIcon title={item.title} size={24} />}
|
||||
</View>
|
||||
|
||||
<Text className="text-text ml-2">{item.title}</Text>
|
||||
</View>
|
||||
)
|
||||
|
||||
const renderFeedItems = ({ item }: { item: PickedFeedModel }) => (
|
||||
<View className="bg-secondary-system-grouped-background h-12 flex-row items-center px-3">
|
||||
<View className="overflow-hidden rounded">
|
||||
<FeedIcon
|
||||
feed={
|
||||
{
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
url: item.url,
|
||||
image: item.image,
|
||||
type: item.view,
|
||||
siteUrl: item.siteUrl || "",
|
||||
} as FeedIconRequiredFeed
|
||||
}
|
||||
size={24}
|
||||
/>
|
||||
</View>
|
||||
<Text className="text-text ml-2">{item.title}</Text>
|
||||
</View>
|
||||
)
|
||||
|
||||
const SectionHeader = ({ title }: { title: string }) => (
|
||||
<View className="my-5 flex-row items-center justify-center gap-4">
|
||||
<View
|
||||
className="bg-secondary-label w-12 rounded-full"
|
||||
style={{ height: StyleSheet.hairlineWidth }}
|
||||
/>
|
||||
<Text className="text-secondary-label text-sm font-medium">{title}</Text>
|
||||
<View
|
||||
className="bg-secondary-label w-12 rounded-full"
|
||||
style={{ height: StyleSheet.hairlineWidth }}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
@@ -11,11 +11,20 @@ import {
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from "react-native"
|
||||
import Animated, { useAnimatedScrollHandler, useSharedValue } from "react-native-reanimated"
|
||||
import Animated, {
|
||||
interpolate,
|
||||
useAnimatedScrollHandler,
|
||||
useAnimatedStyle,
|
||||
useSharedValue,
|
||||
} from "react-native-reanimated"
|
||||
import { useSafeAreaFrame, useSafeAreaInsets } from "react-native-safe-area-context"
|
||||
|
||||
import { ReAnimatedScrollView } from "@/src/components/common/AnimatedComponents"
|
||||
import { BlurEffect } from "@/src/components/common/BlurEffect"
|
||||
import {
|
||||
InternalNavigationHeader,
|
||||
UINavigationHeaderActionButton,
|
||||
} from "@/src/components/layouts/header/NavigationHeader"
|
||||
import { getDefaultHeaderHeight } from "@/src/components/layouts/utils"
|
||||
import { FallbackIcon } from "@/src/components/ui/icon/fallback-icon"
|
||||
import type { FeedIconRequiredFeed } from "@/src/components/ui/icon/feed-icon"
|
||||
@@ -84,6 +93,21 @@ function ProfileScreenImpl(props: { userId: string }) {
|
||||
|
||||
return (
|
||||
<View className="bg-system-grouped-background flex-1">
|
||||
<Animated.View
|
||||
pointerEvents="box-none"
|
||||
className="border-system-fill border-hairline absolute inset-x-0 top-0 z-[99]"
|
||||
style={{ opacity: headerOpacity }}
|
||||
>
|
||||
<BlurEffect />
|
||||
<InternalNavigationHeader
|
||||
title={`${user?.name}'s Profile`}
|
||||
headerRight={
|
||||
<UINavigationHeaderActionButton onPress={openShareUrl}>
|
||||
<Share3CuteReIcon color={textLabelColor} />
|
||||
</UINavigationHeaderActionButton>
|
||||
}
|
||||
/>
|
||||
</Animated.View>
|
||||
<ReAnimatedScrollView
|
||||
nestedScrollEnabled
|
||||
onScroll={scrollHandler}
|
||||
@@ -95,30 +119,16 @@ function ProfileScreenImpl(props: { userId: string }) {
|
||||
{!isLoading && subscriptions && <SubscriptionList subscriptions={subscriptions.data} />}
|
||||
</ReAnimatedScrollView>
|
||||
|
||||
<View
|
||||
style={{ height: headerHeight }}
|
||||
className="absolute top-0 w-full flex-row items-center justify-between px-4"
|
||||
<Animated.View
|
||||
style={useAnimatedStyle(() => ({
|
||||
opacity: interpolate(headerOpacity.value, [0, 1], [1, 0]),
|
||||
}))}
|
||||
className="absolute top-5 w-full flex-row items-center justify-between px-4"
|
||||
>
|
||||
<View />
|
||||
<TouchableOpacity onPress={openShareUrl}>
|
||||
<Share3CuteReIcon color="#fff" />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
{/* Header */}
|
||||
<Animated.View
|
||||
pointerEvents="none"
|
||||
className="border-b-hairline border-opaque-separator absolute inset-x-0 top-0 flex-row items-center px-4"
|
||||
style={{ opacity: headerOpacity, height: headerHeight }}
|
||||
>
|
||||
<BlurEffect />
|
||||
|
||||
<Text className="text-label flex-1 text-center text-lg font-medium">
|
||||
{user?.name}'s Profile
|
||||
</Text>
|
||||
|
||||
<TouchableOpacity onPress={openShareUrl}>
|
||||
<Share3CuteReIcon color={textLabelColor} />
|
||||
</TouchableOpacity>
|
||||
</Animated.View>
|
||||
</View>
|
||||
)
|
||||
|
||||
@@ -34,7 +34,6 @@ export function Settings() {
|
||||
<>
|
||||
<SafeNavigationScrollView
|
||||
ref={scrollViewRef}
|
||||
scrollEventThrottle={16}
|
||||
style={{ paddingTop: insets.top }}
|
||||
className="bg-system-grouped-background flex-1"
|
||||
contentViewClassName="-mt-24"
|
||||
|
||||
Reference in New Issue
Block a user