| ... | ... | @@ -31,6 +31,7 @@ import { useThreadPr } from "../../state/use-thread-pr"; |
| 31 | 31 | import { ThreadSwipeable } from "../home/thread-swipe-actions"; |
| 32 | 32 | import { buildThreadTitleRegenerationMenuItems } from "./thread-title-regeneration-menu"; |
| 33 | 33 | import { |
| 34 | THREAD_LIST_V2_SETTLED_PAGE_COUNT, |
| 34 | 35 | resolveThreadListV2SnoozeMenuSelection, |
| 35 | 36 | resolveThreadListV2SnoozeGateExpiryMs, |
| 36 | 37 | resolveThreadListV2Status, |
| ... | ... | @@ -95,96 +96,130 @@ const LEGACY_MENU_ACTIONS: MenuAction[] = [ |
| 95 | 96 | /** Rounded-row radius shared with the v1 sidebar rows. */ |
| 96 | 97 | const SIDEBAR_V2_ROW_RADIUS = 12; |
| 97 | 98 | |
| 98 | | /** Section label + rule: the only structure in an otherwise flat list. */ |
| 99 | | export const ThreadListV2SectionDivider = memo(function ThreadListV2SectionDivider(props: { |
| 99 | function ThreadListV2Section(props: { |
| 100 | 100 | readonly label: string; |
| 101 | 101 | readonly pane?: "screen" | "sidebar"; |
| 102 | readonly tone?: "default" | "snoozed"; |
| 103 | readonly disclosure?: { |
| 104 | readonly expanded: boolean; |
| 105 | readonly disabled?: boolean; |
| 106 | readonly onToggle: () => void; |
| 107 | readonly accessibilityLabel: string; |
| 108 | readonly accessibilityHint: string; |
| 109 | }; |
| 102 | 110 | }) { |
| 103 | | return ( |
| 104 | | <View |
| 105 | | className={cn( |
| 106 | | "mb-1.5 mt-4 flex-row items-center gap-2.5", |
| 107 | | props.pane === "sidebar" ? "px-3" : "px-5", |
| 108 | | )} |
| 109 | | > |
| 110 | | <Text className="text-xs font-t3-medium text-foreground-tertiary">{props.label}</Text> |
| 111 | | <View className="h-px flex-1 bg-border" /> |
| 112 | | </View> |
| 111 | const snoozed = props.tone === "snoozed"; |
| 112 | const className = cn( |
| 113 | "mb-1.5 mt-4 flex-row items-center gap-2.5", |
| 114 | props.pane === "sidebar" ? "px-3" : "px-5", |
| 115 | ); |
| 116 | const content = ( |
| 117 | <> |
| 118 | <Text |
| 119 | className={cn( |
| 120 | "text-xs font-t3-medium", |
| 121 | snoozed ? "text-foreground-secondary" : "text-foreground-tertiary", |
| 122 | )} |
| 123 | > |
| 124 | {props.label} |
| 125 | </Text> |
| 126 | <View className={cn("h-px flex-1", snoozed ? "bg-primary/20" : "bg-border")} /> |
| 127 | {props.disclosure ? ( |
| 128 | <SymbolView |
| 129 | name="chevron.down" |
| 130 | size={10} |
| 131 | tintColorClassName={snoozed ? "accent-icon-muted" : "accent-foreground-muted"} |
| 132 | type="monochrome" |
| 133 | style={{ transform: [{ rotate: props.disclosure.expanded ? "180deg" : "0deg" }] }} |
| 134 | /> |
| 135 | ) : null} |
| 136 | </> |
| 113 | 137 | ); |
| 114 | | }); |
| 115 | 138 | |
| 116 | | export const ThreadListV2SnoozedShelfHeader = memo(function ThreadListV2SnoozedShelfHeader(props: { |
| 117 | | readonly count: number; |
| 118 | | readonly disabled?: boolean; |
| 119 | | readonly expanded: boolean; |
| 120 | | readonly onToggle: () => void; |
| 121 | | readonly pane?: "screen" | "sidebar"; |
| 122 | | }) { |
| 123 | | return ( |
| 139 | return props.disclosure ? ( |
| 124 | 140 | <Pressable |
| 125 | | accessibilityHint={ |
| 126 | | props.expanded ? "Collapses the snoozed threads." : "Expands the snoozed threads." |
| 127 | | } |
| 128 | | accessibilityLabel={props.count === 1 ? "1 snoozed thread" : `${props.count} snoozed threads`} |
| 141 | accessibilityHint={props.disclosure.accessibilityHint} |
| 142 | accessibilityLabel={props.disclosure.accessibilityLabel} |
| 129 | 143 | accessibilityRole="button" |
| 130 | | accessibilityState={{ disabled: props.disabled, expanded: props.expanded }} |
| 131 | | className={cn( |
| 132 | | "mb-1.5 mt-4 flex-row items-center gap-2.5", |
| 133 | | props.pane === "sidebar" ? "px-3" : "px-5", |
| 134 | | )} |
| 135 | | disabled={props.disabled} |
| 136 | | onPress={props.onToggle} |
| 144 | accessibilityState={{ |
| 145 | disabled: props.disclosure.disabled, |
| 146 | expanded: props.disclosure.expanded, |
| 147 | }} |
| 148 | className={className} |
| 149 | disabled={props.disclosure.disabled} |
| 150 | onPress={props.disclosure.onToggle} |
| 137 | 151 | style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })} |
| 138 | 152 | > |
| 139 | | <Text className="text-xs font-t3-medium text-foreground-secondary"> |
| 140 | | {props.expanded ? "Snoozed" : `Snoozed (${props.count})`} |
| 141 | | </Text> |
| 142 | | <View className="h-px flex-1 bg-primary/20" /> |
| 143 | | <SymbolView |
| 144 | | name="chevron.down" |
| 145 | | size={10} |
| 146 | | tintColorClassName="accent-icon-muted" |
| 147 | | type="monochrome" |
| 148 | | style={{ transform: [{ rotate: props.expanded ? "180deg" : "0deg" }] }} |
| 149 | | /> |
| 153 | {content} |
| 150 | 154 | </Pressable> |
| 155 | ) : ( |
| 156 | <View className={className}>{content}</View> |
| 151 | 157 | ); |
| 158 | } |
| 159 | |
| 160 | /** Section label + rule: the only structure in an otherwise flat list. */ |
| 161 | export const ThreadListV2SectionDivider = memo(function ThreadListV2SectionDivider(props: { |
| 162 | readonly label: string; |
| 163 | readonly pane?: "screen" | "sidebar"; |
| 164 | }) { |
| 165 | return <ThreadListV2Section {...props} />; |
| 152 | 166 | }); |
| 153 | 167 | |
| 154 | | export const ThreadListV2SettledShelfHeader = memo(function ThreadListV2SettledShelfHeader(props: { |
| 168 | type ThreadListV2ShelfHeaderProps = { |
| 155 | 169 | readonly count: number; |
| 156 | 170 | readonly disabled?: boolean; |
| 157 | 171 | readonly expanded: boolean; |
| 158 | 172 | readonly onToggle: () => void; |
| 159 | 173 | readonly pane?: "screen" | "sidebar"; |
| 174 | }; |
| 175 | |
| 176 | function ThreadListV2ShelfHeader( |
| 177 | props: ThreadListV2ShelfHeaderProps & { readonly kind: "snoozed" | "settled" }, |
| 178 | ) { |
| 179 | const label = props.kind === "snoozed" ? "Snoozed" : "Settled"; |
| 180 | return ( |
| 181 | <ThreadListV2Section |
| 182 | label={props.expanded ? label : `${label} (${props.count})`} |
| 183 | pane={props.pane} |
| 184 | tone={props.kind === "snoozed" ? "snoozed" : "default"} |
| 185 | disclosure={{ |
| 186 | expanded: props.expanded, |
| 187 | disabled: props.disabled, |
| 188 | onToggle: props.onToggle, |
| 189 | accessibilityLabel: `${props.count} ${props.kind} ${props.count === 1 ? "thread" : "threads"}`, |
| 190 | accessibilityHint: `${props.expanded ? "Collapses" : "Expands"} the ${props.kind} threads.`, |
| 191 | }} |
| 192 | /> |
| 193 | ); |
| 194 | } |
| 195 | |
| 196 | export const ThreadListV2SnoozedShelfHeader = memo(function ThreadListV2SnoozedShelfHeader( |
| 197 | props: ThreadListV2ShelfHeaderProps, |
| 198 | ) { |
| 199 | return <ThreadListV2ShelfHeader {...props} kind="snoozed" />; |
| 200 | }); |
| 201 | |
| 202 | export const ThreadListV2SettledShelfHeader = memo(function ThreadListV2SettledShelfHeader( |
| 203 | props: ThreadListV2ShelfHeaderProps, |
| 204 | ) { |
| 205 | return <ThreadListV2ShelfHeader {...props} kind="settled" />; |
| 206 | }); |
| 207 | |
| 208 | export const ThreadListV2ShowMoreRow = memo(function ThreadListV2ShowMoreRow(props: { |
| 209 | readonly hiddenCount: number; |
| 210 | readonly onPress: () => void; |
| 160 | 211 | }) { |
| 161 | 212 | return ( |
| 162 | 213 | <Pressable |
| 163 | | accessibilityHint={ |
| 164 | | props.expanded ? "Collapses the settled threads." : "Expands the settled threads." |
| 165 | | } |
| 166 | | accessibilityLabel={props.count === 1 ? "1 settled thread" : `${props.count} settled threads`} |
| 167 | 214 | accessibilityRole="button" |
| 168 | | accessibilityState={{ disabled: props.disabled, expanded: props.expanded }} |
| 169 | | className={cn( |
| 170 | | "mb-1.5 mt-4 flex-row items-center gap-2.5", |
| 171 | | props.pane === "sidebar" ? "px-3" : "px-5", |
| 172 | | )} |
| 173 | | disabled={props.disabled} |
| 174 | | onPress={props.onToggle} |
| 215 | accessibilityLabel={`Show ${Math.min(props.hiddenCount, THREAD_LIST_V2_SETTLED_PAGE_COUNT)} more settled threads`} |
| 216 | onPress={props.onPress} |
| 217 | className="mx-4 mt-2 items-center rounded-lg border border-dashed border-border py-2.5" |
| 175 | 218 | style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })} |
| 176 | 219 | > |
| 177 | | <Text className="text-xs font-t3-medium text-foreground-tertiary"> |
| 178 | | {props.expanded ? "Settled" : `Settled (${props.count})`} |
| 220 | <Text className="text-xs font-t3-medium text-foreground-muted"> |
| 221 | Show more ({props.hiddenCount} settled hidden) |
| 179 | 222 | </Text> |
| 180 | | <View className="h-px flex-1 bg-border" /> |
| 181 | | <SymbolView |
| 182 | | name="chevron.down" |
| 183 | | size={10} |
| 184 | | tintColorClassName="accent-foreground-muted" |
| 185 | | type="monochrome" |
| 186 | | style={{ transform: [{ rotate: props.expanded ? "180deg" : "0deg" }] }} |
| 187 | | /> |
| 188 | 223 | </Pressable> |
| 189 | 224 | ); |
| 190 | 225 | }); |