Profile: add menu and load more button

This commit is contained in:
thislight 2024-10-25 22:37:50 +08:00
parent 88731c07b7
commit 556e0b2336

View file

@ -2,14 +2,34 @@ import {
createRenderEffect, createRenderEffect,
createResource, createResource,
createSignal, createSignal,
createUniqueId,
For, For,
onCleanup, onCleanup,
Show, Show,
type Component, type Component,
} from "solid-js"; } from "solid-js";
import Scaffold from "../material/Scaffold"; import Scaffold from "../material/Scaffold";
import { AppBar, Avatar, Button, IconButton, Toolbar } from "@suid/material"; import {
import { Close, MoreVert, Verified } from "@suid/icons-material"; AppBar,
Avatar,
Button,
Divider,
IconButton,
ListItemIcon,
ListItemText,
MenuItem,
Toolbar,
} from "@suid/material";
import {
Close,
Edit,
ExpandMore,
MoreVert,
OpenInBrowser,
Send,
Share,
Verified,
} from "@suid/icons-material";
import { Title } from "../material/typography"; import { Title } from "../material/typography";
import { useNavigate, useParams } from "@solidjs/router"; import { useNavigate, useParams } from "@solidjs/router";
import { useSessionForAcctStr } from "../masto/clients"; import { useSessionForAcctStr } from "../masto/clients";
@ -21,6 +41,8 @@ import { createTimeline } from "../masto/timelines";
import TootList from "../timelines/TootList"; import TootList from "../timelines/TootList";
import { createTimeSource, TimeSourceProvider } from "../platform/timesrc"; import { createTimeSource, TimeSourceProvider } from "../platform/timesrc";
import TootFilterButton from "./TootFilterButton"; import TootFilterButton from "./TootFilterButton";
import Menu from "../material/Menu";
import { share } from "../platform/share";
const Profile: Component = () => { const Profile: Component = () => {
const navigate = useNavigate(); const navigate = useNavigate();
@ -34,6 +56,10 @@ const Profile: Component = () => {
const windowSize = useWindowSize(); const windowSize = useWindowSize();
const time = createTimeSource(); const time = createTimeSource();
const menuButId = createUniqueId();
const [menuOpen, setMenuOpen] = createSignal(false);
const [scrolledPastBanner, setScrolledPastBanner] = createSignal(false); const [scrolledPastBanner, setScrolledPastBanner] = createSignal(false);
const obx = new IntersectionObserver( const obx = new IntersectionObserver(
(entries) => { (entries) => {
@ -58,12 +84,13 @@ const Profile: Component = () => {
); );
const [recentTootFilter, setRecentTootFilter] = createSignal({ const [recentTootFilter, setRecentTootFilter] = createSignal({
boost: true, boost: false,
reply: true, reply: true,
original: true, original: true,
}); });
const [recentToots] = createTimeline( const [recentToots, recentTootChunk, { refetch: refetchRecentToots }] =
createTimeline(
() => session().client.v1.accounts.$select(params.id).statuses, () => session().client.v1.accounts.$select(params.id).statuses,
() => { () => {
const { boost, reply } = recentTootFilter(); const { boost, reply } = recentTootFilter();
@ -140,7 +167,11 @@ const Profile: Component = () => {
paddingTop: "var(--safe-area-inset-top)", paddingTop: "var(--safe-area-inset-top)",
}} }}
> >
<IconButton color="inherit" onClick={[navigate, -1]}> <IconButton
color="inherit"
onClick={[navigate, -1]}
aria-label="Close"
>
<Close /> <Close />
</IconButton> </IconButton>
<Title <Title
@ -153,13 +184,52 @@ const Profile: Component = () => {
createRenderEffect(() => (e.innerHTML = displayName())) createRenderEffect(() => (e.innerHTML = displayName()))
} }
></Title> ></Title>
<IconButton color="inherit">
<IconButton
id={menuButId}
color="inherit"
onClick={[setMenuOpen, true]}
>
<MoreVert /> <MoreVert />
</IconButton> </IconButton>
</Toolbar> </Toolbar>
</AppBar> </AppBar>
} }
> >
<Menu
open={menuOpen()}
onClose={[setMenuOpen, false]}
anchor={() =>
document.getElementById(menuButId)!.getBoundingClientRect()
}
>
<MenuItem disabled>
<ListItemIcon>
<Edit />
</ListItemIcon>
<ListItemText>Edit...</ListItemText>
</MenuItem>
<Divider />
<MenuItem disabled>
<ListItemIcon>
<Send />
</ListItemIcon>
<ListItemText>Mention {profile()?.displayName || ""}...</ListItemText>
</MenuItem>
<Divider />
<MenuItem component={"a"} href={profile()?.url} target="_blank" rel="noopener noreferrer">
<ListItemIcon>
<OpenInBrowser />
</ListItemIcon>
<ListItemText>Open in browser...</ListItemText>
</MenuItem>
<MenuItem onClick={() => share({ url: profile()?.url })}>
<ListItemIcon>
<Share />
</ListItemIcon>
<ListItemText>Share...</ListItemText>
</MenuItem>
</Menu>
<div <div
style={{ style={{
width: "100%", width: "100%",
@ -251,7 +321,7 @@ const Profile: Component = () => {
<div> <div>
<TootFilterButton <TootFilterButton
options={{ options={{
boost: "Boosteds", boost: "Boosts",
reply: "Replies", reply: "Replies",
original: "Originals", original: "Originals",
}} }}
@ -268,6 +338,24 @@ const Profile: Component = () => {
onChangeToot={recentToots.set} onChangeToot={recentToots.set}
/> />
</TimeSourceProvider> </TimeSourceProvider>
<Show when={!recentTootChunk()?.done}>
<div
style={{
"text-align": "center",
"padding-bottom": "var(--safe-area-inset-bottom)",
}}
>
<IconButton
aria-label="Load More"
size="large"
color="primary"
onClick={[refetchRecentToots, "prev"]}
>
<ExpandMore />
</IconButton>
</div>
</Show>
</Scaffold> </Scaffold>
); );
}; };