From f36c9565362b741c58672204fe0c155252affe28 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Tue, 24 Jan 2023 13:00:11 -0600 Subject: Resolve all remaining lint issues (#88) * Rework 'navIdx' variables from number arrays to strings to avoid equality-check failures in react hooks * Resolve all remaining lint issues * Fix tests * Use node v18 in gh action test --- .github/workflows/lint.yml | 4 + __tests__/state/models/navigation.test.ts | 4 +- jest/test-pds.ts | 1 - metro.config.js | 2 - src/App.native.tsx | 3 +- src/lib/strings.ts | 22 +- src/state/models/navigation.ts | 17 +- src/view/com/composer/ComposePost.tsx | 6 +- src/view/com/discover/SuggestedFollows.tsx | 6 +- src/view/com/login/Signin.tsx | 15 +- src/view/com/modals/EditProfile.tsx | 3 +- src/view/com/modals/ServerInput.tsx | 2 +- src/view/com/notifications/Feed.tsx | 19 +- src/view/com/onboard/FeatureExplainer.tsx | 20 +- src/view/com/post-thread/PostRepostedBy.tsx | 6 +- src/view/com/post-thread/PostThread.tsx | 11 +- src/view/com/post-thread/PostThreadItem.tsx | 16 +- src/view/com/post-thread/PostVotedBy.tsx | 6 +- src/view/com/post/Post.tsx | 8 +- src/view/com/post/PostText.tsx | 12 +- src/view/com/posts/Feed.tsx | 19 +- src/view/com/posts/FeedItem.tsx | 9 +- src/view/com/profile/ProfileFollowers.tsx | 6 +- src/view/com/profile/ProfileFollows.tsx | 6 +- src/view/com/profile/ProfileHeader.tsx | 20 +- src/view/com/util/Link.tsx | 2 +- src/view/com/util/LoadingPlaceholder.tsx | 17 +- src/view/com/util/PostCtrls.tsx | 13 +- src/view/com/util/PostEmbeds.tsx | 5 +- src/view/com/util/Selector.tsx | 2 +- src/view/com/util/UserAvatar.tsx | 14 +- src/view/com/util/UserInfoText.tsx | 10 +- src/view/com/util/ViewHeader.tsx | 31 +-- src/view/com/util/ViewSelector.tsx | 5 +- src/view/com/util/forms/RadioGroup.tsx | 3 +- src/view/com/util/gestures/HorzSwipe.tsx | 7 +- src/view/com/util/gestures/SwipeAndZoom.tsx | 3 +- src/view/com/util/images/AutoSizedImage.tsx | 4 +- src/view/com/util/images/ImageLayoutGrid.tsx | 2 +- src/view/lib/styles.ts | 3 + src/view/routes.ts | 2 +- src/view/screens/Contacts.tsx | 2 +- src/view/screens/Debug.tsx | 80 ++------ src/view/screens/Home.tsx | 11 +- src/view/screens/Log.tsx | 4 +- src/view/screens/Login.tsx | 94 +++++---- src/view/screens/NotFound.tsx | 23 ++- src/view/screens/Notifications.tsx | 5 +- src/view/screens/Onboard.tsx | 13 +- src/view/screens/PostDownvotedBy.tsx | 2 +- src/view/screens/PostRepostedBy.tsx | 2 +- src/view/screens/PostThread.tsx | 21 +- src/view/screens/PostUpvotedBy.tsx | 2 +- src/view/screens/Profile.tsx | 19 +- src/view/screens/ProfileFollowers.tsx | 2 +- src/view/screens/ProfileFollows.tsx | 2 +- src/view/screens/Search.tsx | 4 +- src/view/screens/Settings.tsx | 12 +- src/view/shell/mobile/Menu.tsx | 288 +++++++++++++-------------- src/view/shell/mobile/index.tsx | 8 +- 60 files changed, 478 insertions(+), 482 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 54c0ae839..1d9859884 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,6 +25,10 @@ jobs: name: Run tests runs-on: ubuntu-latest steps: + - name: Install node 18 + uses: actions/setup-node@v3 + with: + node-version: 18 - name: Check out Git repository uses: actions/checkout@v2 - name: Yarn install diff --git a/__tests__/state/models/navigation.test.ts b/__tests__/state/models/navigation.test.ts index 284f1f36e..80f66d494 100644 --- a/__tests__/state/models/navigation.test.ts +++ b/__tests__/state/models/navigation.test.ts @@ -6,7 +6,7 @@ describe('NavigationModel', () => { beforeEach(() => { model = new NavigationModel() - model.setTitle([0, 0], 'title') + model.setTitle('0-0', 'title') }) afterAll(() => { @@ -44,7 +44,7 @@ describe('NavigationModel', () => { }) it('should call the isCurrentScreen method', () => { - expect(model.isCurrentScreen(11, 0)).toEqual(false) + expect(model.isCurrentScreen('11', 0)).toEqual(false) }) it('should call the tab getter', () => { diff --git a/jest/test-pds.ts b/jest/test-pds.ts index 4915b58e3..01b37efb0 100644 --- a/jest/test-pds.ts +++ b/jest/test-pds.ts @@ -41,7 +41,6 @@ function* dateGen() { yield new Date(start).toISOString() start += 1e3 } - return '' } export async function createServer(): Promise { diff --git a/metro.config.js b/metro.config.js index 24de9fbdc..c81b3ca13 100644 --- a/metro.config.js +++ b/metro.config.js @@ -4,8 +4,6 @@ * * @format */ -const metroResolver = require('metro-resolver') -const path = require('path') module.exports = { transformer: { diff --git a/src/App.native.tsx b/src/App.native.tsx index 3cce25548..e9d7542c0 100644 --- a/src/App.native.tsx +++ b/src/App.native.tsx @@ -10,6 +10,7 @@ import {ThemeProvider} from './view/lib/ThemeContext' import * as view from './view/index' import {RootStoreModel, setupState, RootStoreProvider} from './state' import {MobileShell} from './view/shell/mobile' +import {s} from './view/lib/styles' const App = observer(() => { const [rootStore, setRootStore] = useState( @@ -39,7 +40,7 @@ const App = observer(() => { } return ( - + diff --git a/src/lib/strings.ts b/src/lib/strings.ts index 24b8bcafa..cb79e8824 100644 --- a/src/lib/strings.ts +++ b/src/lib/strings.ts @@ -78,7 +78,7 @@ export function extractEntities( let ents: Entity[] = [] { // mentions - const re = /(^|\s|\()(@)([a-zA-Z0-9\.-]+)(\b)/g + const re = /(^|\s|\()(@)([a-zA-Z0-9.-]+)(\b)/g while ((match = re.exec(text))) { if (knownHandles && !knownHandles.has(match[3])) { continue // not a known handle @@ -133,7 +133,7 @@ interface DetectedLink { type DetectedLinkable = string | DetectedLink export function detectLinkables(text: string): DetectedLinkable[] { const re = - /((^|\s|\()@[a-z0-9\.-]*)|((^|\s|\()https?:\/\/[\S]+)|((^|\s|\()(?[a-z][a-z0-9]*(\.[a-z0-9]+)+)[\S]*)/gi + /((^|\s|\()@[a-z0-9.-]*)|((^|\s|\()https?:\/\/[\S]+)|((^|\s|\()(?[a-z][a-z0-9]*(\.[a-z0-9]+)+)[\S]*)/gi const segments = [] let match let start = 0 @@ -154,14 +154,12 @@ export function detectLinkables(text: string): DetectedLinkable[] { matchValue = matchValue.slice(1) } - { - // strip ending puncuation - if (/[.,;!?]$/.test(matchValue)) { - matchValue = matchValue.slice(0, -1) - } - if (/[)]$/.test(matchValue) && !matchValue.includes('(')) { - matchValue = matchValue.slice(0, -1) - } + // strip ending puncuation + if (/[.,;!?]$/.test(matchValue)) { + matchValue = matchValue.slice(0, -1) + } + if (/[)]$/.test(matchValue) && !matchValue.includes('(')) { + matchValue = matchValue.slice(0, -1) } if (start !== matchIndex) { @@ -185,8 +183,8 @@ export function makeValidHandle(str: string): string { } export function createFullHandle(name: string, domain: string): string { - name = (name || '').replace(/[\.]+$/, '') - domain = (domain || '').replace(/^[\.]+/, '') + name = (name || '').replace(/[.]+$/, '') + domain = (domain || '').replace(/^[.]+/, '') return `${name}.${domain}` } diff --git a/src/state/models/navigation.ts b/src/state/models/navigation.ts index 8d69e5c04..224ffef0d 100644 --- a/src/state/models/navigation.ts +++ b/src/state/models/navigation.ts @@ -3,7 +3,7 @@ import {TABS_ENABLED} from '../../build-flags' let __id = 0 function genId() { - return ++__id + return String(++__id) } // NOTE @@ -24,10 +24,10 @@ interface HistoryItem { url: string ts: number title?: string - id: number + id: string } -export type HistoryPtr = [number, number] +export type HistoryPtr = string // `{tabId}-{historyId}` export class NavigationTabModel { id = genId() @@ -151,7 +151,7 @@ export class NavigationTabModel { } } - setTitle(id: number, title: string) { + setTitle(id: string, title: string) { this.history = this.history.map(h => { if (h.id === id) { return {...h, title} @@ -174,7 +174,7 @@ export class NavigationTabModel { } } - hydrate(v: unknown) { + hydrate(_v: unknown) { // TODO fixme // if (isObj(v)) { // if (hasProp(v, 'history') && Array.isArray(v.history)) { @@ -241,7 +241,7 @@ export class NavigationModel { return this.tabs.length } - isCurrentScreen(tabId: number, index: number) { + isCurrentScreen(tabId: string, index: number) { return this.tab.id === tabId && this.tab.index === index } @@ -257,7 +257,8 @@ export class NavigationModel { } setTitle(ptr: HistoryPtr, title: string) { - this.tabs.find(t => t.id === ptr[0])?.setTitle(ptr[1], title) + const [tid, hid] = ptr.split('-') + this.tabs.find(t => t.id === tid)?.setTitle(hid, title) } handleLink(url: string) { @@ -338,7 +339,7 @@ export class NavigationModel { } } - hydrate(v: unknown) { + hydrate(_v: unknown) { // TODO fixme this.clear() /*if (isObj(v)) { diff --git a/src/view/com/composer/ComposePost.tsx b/src/view/com/composer/ComposePost.tsx index f0dec4b0a..02b7cae5c 100644 --- a/src/view/com/composer/ComposePost.tsx +++ b/src/view/com/composer/ComposePost.tsx @@ -297,7 +297,7 @@ export const ComposePost = observer(function ComposePost({ ) } }) - }, [text, pal.link]) + }, [text, pal.link, pal.text]) return ( onChangeText(text)} + onChangeText={(str: string) => onChangeText(str)} onPaste={onPaste} placeholder={selectTextInputPlaceholder} placeholderTextColor={pal.colors.textLight} @@ -475,7 +475,7 @@ export const ComposePost = observer(function ComposePost({ ) }) -const atPrefixRegex = /@([a-z0-9\.]*)$/i +const atPrefixRegex = /@([a-z0-9.]*)$/i function extractTextAutocompletePrefix(text: string) { const match = atPrefixRegex.exec(text) if (match) { diff --git a/src/view/com/discover/SuggestedFollows.tsx b/src/view/com/discover/SuggestedFollows.tsx index 87886c652..d2afc4b33 100644 --- a/src/view/com/discover/SuggestedFollows.tsx +++ b/src/view/com/discover/SuggestedFollows.tsx @@ -39,7 +39,7 @@ export const SuggestedFollows = observer( // Using default import (React.use...) instead of named import (use...) to be able to mock store's data in jest environment const view = React.useMemo( () => new SuggestedActorsViewModel(store), - [], + [store], ) useEffect(() => { @@ -54,7 +54,7 @@ export const SuggestedFollows = observer( if (!view.isLoading && !view.hasError && !view.hasContent) { onNoSuggestions?.() } - }, [view, view.isLoading, view.hasError, view.hasContent]) + }, [view, view.isLoading, view.hasError, view.hasContent, onNoSuggestions]) const onPressTryAgain = () => view @@ -128,7 +128,7 @@ export const SuggestedFollows = observer( keyExtractor={item => item._reactKey} renderItem={renderItem} style={s.flex1} - contentContainerStyle={{paddingBottom: 200}} + contentContainerStyle={s.contentContainer} /> )} diff --git a/src/view/com/login/Signin.tsx b/src/view/com/login/Signin.tsx index a39ea5e74..f0637db8d 100644 --- a/src/view/com/login/Signin.tsx +++ b/src/view/com/login/Signin.tsx @@ -207,12 +207,7 @@ const ChooseAccountForm = ({ style={[pal.borderDark, styles.group]} onPress={() => onSelectAccount(undefined)}> - - - - + Other account @@ -556,7 +551,7 @@ const ForgotPasswordForm = ({ {!serviceDescription || isProcessing ? ( ) : !email ? ( - + Next ) : ( @@ -691,7 +686,7 @@ const SetNewPasswordForm = ({ {isProcessing ? ( ) : !resetCode || !password ? ( - + Next ) : ( @@ -810,6 +805,9 @@ const styles = StyleSheet.create({ alignItems: 'baseline', paddingVertical: 10, }, + accountTextOther: { + paddingLeft: 12, + }, error: { backgroundColor: colors.red4, flexDirection: 'row', @@ -832,4 +830,5 @@ const styles = StyleSheet.create({ justifyContent: 'center', marginRight: 5, }, + dimmed: {opacity: 0.5}, }) diff --git a/src/view/com/modals/EditProfile.tsx b/src/view/com/modals/EditProfile.tsx index f830f39e8..ba99feb32 100644 --- a/src/view/com/modals/EditProfile.tsx +++ b/src/view/com/modals/EditProfile.tsx @@ -121,7 +121,7 @@ export function Component({ {error !== '' && ( - + )} @@ -231,4 +231,5 @@ const styles = StyleSheet.create({ marginBottom: 36, marginHorizontal: -14, }, + errorContainer: {marginTop: 20}, }) diff --git a/src/view/com/modals/ServerInput.tsx b/src/view/com/modals/ServerInput.tsx index 8792d70f1..31ef4b12d 100644 --- a/src/view/com/modals/ServerInput.tsx +++ b/src/view/com/modals/ServerInput.tsx @@ -56,7 +56,7 @@ export function Component({onSelect}: {onSelect: (url: string) => void}) { Other service - + ) } @@ -58,14 +59,10 @@ export const Feed = observer(function Feed({ } } return ( - + {view.isLoading && !data && } {view.hasError && ( - + )} {data && ( )} ) }) + +const styles = StyleSheet.create({ + emptyState: {paddingVertical: 40}, +}) diff --git a/src/view/com/onboard/FeatureExplainer.tsx b/src/view/com/onboard/FeatureExplainer.tsx index 78ace5189..03e050883 100644 --- a/src/view/com/onboard/FeatureExplainer.tsx +++ b/src/view/com/onboard/FeatureExplainer.tsx @@ -19,14 +19,13 @@ import {TABS_ENABLED} from '../../../build-flags' const Intro = () => ( - Welcome to Bluesky + style={[styles.explainerHeading, s.normal, styles.explainerHeadingIntro]}> + Welcome to{' '} + + Bluesky + - + This is an early beta. Your feedback is appreciated! @@ -161,11 +160,18 @@ const styles = StyleSheet.create({ textAlign: 'center', marginBottom: 16, }, + explainerHeadingIntro: { + lineHeight: 60, + paddingTop: 50, + paddingBottom: 50, + }, + explainerHeadingBrand: {fontSize: 56}, explainerDesc: { fontSize: 18, textAlign: 'center', marginBottom: 16, }, + explainerDescIntro: {fontSize: 24}, explainerImg: { resizeMode: 'contain', maxWidth: '100%', diff --git a/src/view/com/post-thread/PostRepostedBy.tsx b/src/view/com/post-thread/PostRepostedBy.tsx index c68ceee0b..02d61b47b 100644 --- a/src/view/com/post-thread/PostRepostedBy.tsx +++ b/src/view/com/post-thread/PostRepostedBy.tsx @@ -53,11 +53,7 @@ export const PostRepostedBy = observer(function PostRepostedBy({ if (view.hasError) { return ( - + ) } diff --git a/src/view/com/post-thread/PostThread.tsx b/src/view/com/post-thread/PostThread.tsx index dcdc1eb49..a52bc643c 100644 --- a/src/view/com/post-thread/PostThread.tsx +++ b/src/view/com/post-thread/PostThread.tsx @@ -7,6 +7,7 @@ import { } from '../../../state/models/post-thread-view' import {PostThreadItem} from './PostThreadItem' import {ErrorMessage} from '../util/error/ErrorMessage' +import {s} from '../../lib/styles' export const PostThread = observer(function PostThread({ uri, @@ -60,11 +61,7 @@ export const PostThread = observer(function PostThread({ if (view.hasError) { return ( - + ) } @@ -84,8 +81,8 @@ export const PostThread = observer(function PostThread({ onRefresh={onRefresh} onLayout={onLayout} onScrollToIndexFailed={onScrollToIndexFailed} - style={{flex: 1}} - contentContainerStyle={{paddingBottom: 200}} + style={s.h100pct} + contentContainerStyle={s.contentContainer} /> ) }) diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index 2c7ab716c..92f7acc03 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -80,7 +80,7 @@ export const PostThreadItem = observer(function PostThreadItem({ .catch(e => store.log.error('Failed to toggle upvote', e)) } const onCopyPostText = () => { - Clipboard.setString(record.text) + Clipboard.setString(record?.text || '') Toast.show('Copied to clipboard') } const onDeletePost = () => { @@ -131,8 +131,8 @@ export const PostThreadItem = observer(function PostThreadItem({ - - + + - ) : ( - - )} - + ) : undefined} + - + ) } diff --git a/src/view/com/post/Post.tsx b/src/view/com/post/Post.tsx index 08e560bda..d00cc83c2 100644 --- a/src/view/com/post/Post.tsx +++ b/src/view/com/post/Post.tsx @@ -156,7 +156,7 @@ export const Post = observer(function Post({ timestamp={item.post.indexedAt} /> {replyAuthorDid !== '' && ( - + - ) : ( - - )} - + ) : undefined} + - - - + + + ) } @@ -56,3 +56,7 @@ export const PostText = observer(function PostText({ ) }) + +const styles = StyleSheet.create({ + mt6: {marginTop: 6}, +}) diff --git a/src/view/com/posts/Feed.tsx b/src/view/com/posts/Feed.tsx index 726338f81..db6877660 100644 --- a/src/view/com/posts/Feed.tsx +++ b/src/view/com/posts/Feed.tsx @@ -5,6 +5,7 @@ import { View, FlatList, StyleProp, + StyleSheet, ViewStyle, } from 'react-native' import {PostFeedLoadingPlaceholder} from '../util/LoadingPlaceholder' @@ -14,6 +15,7 @@ import {FeedModel} from '../../../state/models/feed-view' import {FeedItem} from './FeedItem' import {PromptButtons} from './PromptButtons' import {OnScrollCb} from '../../lib/hooks/useOnMainScroll' +import {s} from '../../lib/styles' const COMPOSE_PROMPT_ITEM = {_reactKey: '__prompt__'} const EMPTY_FEED_ITEM = {_reactKey: '__empty__'} @@ -47,7 +49,7 @@ export const Feed = observer(function Feed({ ) } else { @@ -76,7 +78,7 @@ export const Feed = observer(function Feed({ } const FeedFooter = () => feed.isLoading ? ( - + ) : ( @@ -87,11 +89,7 @@ export const Feed = observer(function Feed({ {!data && } {feed.isLoading && !data && } {feed.hasError && ( - + )} {feed.hasLoaded && data && ( ) }) + +const styles = StyleSheet.create({ + feedFooter: {paddingTop: 20}, + emptyState: {paddingVertical: 40}, +}) diff --git a/src/view/com/posts/FeedItem.tsx b/src/view/com/posts/FeedItem.tsx index 4133c17d4..584fa0973 100644 --- a/src/view/com/posts/FeedItem.tsx +++ b/src/view/com/posts/FeedItem.tsx @@ -124,7 +124,7 @@ export const FeedItem = observer(function ({ style={[ styles.bottomReplyLine, {borderColor: pal.colors.replyLine}, - isNoTop ? {top: 64} : undefined, + isNoTop ? styles.bottomReplyLineNoTop : undefined, ]} /> )} @@ -163,7 +163,7 @@ export const FeedItem = observer(function ({ timestamp={item.post.indexedAt} /> {!isChild && replyAuthorDid !== '' && ( - + - ) : ( - - )} + ) : undefined} {item.post.embed ? ( ) : null} @@ -281,6 +279,7 @@ const styles = StyleSheet.create({ bottom: 0, borderLeftWidth: 2, }, + bottomReplyLineNoTop: {top: 64}, includeReason: { flexDirection: 'row', paddingLeft: 50, diff --git a/src/view/com/profile/ProfileFollowers.tsx b/src/view/com/profile/ProfileFollowers.tsx index b1dfbe996..00207c4d2 100644 --- a/src/view/com/profile/ProfileFollowers.tsx +++ b/src/view/com/profile/ProfileFollowers.tsx @@ -54,11 +54,7 @@ export const ProfileFollowers = observer(function ProfileFollowers({ if (view.hasError) { return ( - + ) } diff --git a/src/view/com/profile/ProfileFollows.tsx b/src/view/com/profile/ProfileFollows.tsx index fca12d11b..2e67873c8 100644 --- a/src/view/com/profile/ProfileFollows.tsx +++ b/src/view/com/profile/ProfileFollows.tsx @@ -54,11 +54,7 @@ export const ProfileFollows = observer(function ProfileFollows({ if (view.hasError) { return ( - + ) } diff --git a/src/view/com/profile/ProfileHeader.tsx b/src/view/com/profile/ProfileHeader.tsx index c14a5c827..2f98fce2d 100644 --- a/src/view/com/profile/ProfileHeader.tsx +++ b/src/view/com/profile/ProfileHeader.tsx @@ -100,22 +100,14 @@ export const ProfileHeader = observer(function ProfileHeader({ - + - + - + {view.displayName || view.handle} @@ -208,7 +200,7 @@ export const ProfileHeader = observer(function ProfileHeader({ ) : undefined} - + {view.displayName || view.handle} @@ -349,6 +341,7 @@ const styles = StyleSheet.create({ // paddingLeft: 86, // marginBottom: 14, }, + title: {lineHeight: 38}, handleLine: { flexDirection: 'row', @@ -369,4 +362,7 @@ const styles = StyleSheet.create({ alignItems: 'center', marginBottom: 5, }, + + br40: {borderRadius: 40}, + br50: {borderRadius: 50}, }) diff --git a/src/view/com/util/Link.tsx b/src/view/com/util/Link.tsx index aacdc3272..1cbb1af83 100644 --- a/src/view/com/util/Link.tsx +++ b/src/view/com/util/Link.tsx @@ -57,7 +57,7 @@ export const Link = observer(function Link({ ) }) -export const TextLink = observer(function Link({ +export const TextLink = observer(function TextLink({ type = 'md', style, href, diff --git a/src/view/com/util/LoadingPlaceholder.tsx b/src/view/com/util/LoadingPlaceholder.tsx index 207a3f5d2..9828058e8 100644 --- a/src/view/com/util/LoadingPlaceholder.tsx +++ b/src/view/com/util/LoadingPlaceholder.tsx @@ -19,23 +19,15 @@ export function LoadingPlaceholder({ return ( - - + ]} + /> ) } @@ -137,6 +129,9 @@ export function NotificationFeedLoadingPlaceholder() { } const styles = StyleSheet.create({ + loadingPlaceholder: { + borderRadius: 6, + }, post: { flexDirection: 'row', padding: 10, diff --git a/src/view/com/util/PostCtrls.tsx b/src/view/com/util/PostCtrls.tsx index 0ca13b62f..bde44abab 100644 --- a/src/view/com/util/PostCtrls.tsx +++ b/src/view/com/util/PostCtrls.tsx @@ -128,10 +128,7 @@ export function PostCtrls(opts: PostCtrlsOpts) { hitSlop={HITSLOP} onPress={opts.onPressReply}> @@ -181,10 +178,7 @@ export function PostCtrls(opts: PostCtrlsOpts) { /> ) : ( @@ -244,4 +238,7 @@ const styles = StyleSheet.create({ ctrlIconUpvoted: { color: colors.red3, }, + mt1: { + marginTop: 1, + }, }) diff --git a/src/view/com/util/PostEmbeds.tsx b/src/view/com/util/PostEmbeds.tsx index 65518470a..e3fca2538 100644 --- a/src/view/com/util/PostEmbeds.tsx +++ b/src/view/com/util/PostEmbeds.tsx @@ -67,7 +67,7 @@ export function PostEmbeds({ openLightbox(0)} - containerStyle={{borderRadius: 8}} + containerStyle={styles.singleImage} /> ) @@ -120,6 +120,9 @@ const styles = StyleSheet.create({ imagesContainer: { marginTop: 4, }, + singleImage: { + borderRadius: 8, + }, extOuter: { borderWidth: 1, borderRadius: 8, diff --git a/src/view/com/util/Selector.tsx b/src/view/com/util/Selector.tsx index 7a8b9b530..87540cf38 100644 --- a/src/view/com/util/Selector.tsx +++ b/src/view/com/util/Selector.tsx @@ -41,7 +41,7 @@ export function Selector({ width: middle.width, } return [left, middle, right] - }, [selectedIndex, items, itemLayouts]) + }, [selectedIndex, itemLayouts]) const underlineStyle = { backgroundColor: pal.colors.text, diff --git a/src/view/com/util/UserAvatar.tsx b/src/view/com/util/UserAvatar.tsx index bd4897ba8..c9c255f46 100644 --- a/src/view/com/util/UserAvatar.tsx +++ b/src/view/com/util/UserAvatar.tsx @@ -62,8 +62,8 @@ export function UserAvatar({ ]) }, [onSelectNewAvatar]) - const renderSvg = (size: number, initials: string) => ( - + const renderSvg = (svgSize: number, svgInitials: string) => ( + @@ -78,7 +78,7 @@ export function UserAvatar({ x="50" y="67" textAnchor="middle"> - {initials} + {svgInitials} ) @@ -88,7 +88,11 @@ export function UserAvatar({ {avatar ? ( ) : ( @@ -104,7 +108,7 @@ export function UserAvatar({ ) : avatar ? ( diff --git a/src/view/com/util/UserInfoText.tsx b/src/view/com/util/UserInfoText.tsx index 151fa54d0..a6daf18b2 100644 --- a/src/view/com/util/UserInfoText.tsx +++ b/src/view/com/util/UserInfoText.tsx @@ -1,6 +1,6 @@ import React, {useState, useEffect} from 'react' import {AppBskyActorGetProfile as GetProfile} from '@atproto/api' -import {StyleProp, TextStyle} from 'react-native' +import {StyleProp, StyleSheet, TextStyle} from 'react-native' import {Link} from './Link' import {Text} from './text/Text' import {LoadingPlaceholder} from './LoadingPlaceholder' @@ -53,7 +53,7 @@ export function UserInfoText({ return () => { aborted = true } - }, [did, store.api.app.bsky]) + }, [did, store.profiles]) let inner if (didFail) { @@ -73,7 +73,7 @@ export function UserInfoText({ ) } @@ -91,3 +91,7 @@ export function UserInfoText({ return inner } + +const styles = StyleSheet.create({ + loadingPlaceholder: {position: 'relative', top: 1, left: 2}, +}) diff --git a/src/view/com/util/ViewHeader.tsx b/src/view/com/util/ViewHeader.tsx index 761553cc5..c8b1b2d97 100644 --- a/src/view/com/util/ViewHeader.tsx +++ b/src/view/com/util/ViewHeader.tsx @@ -11,8 +11,8 @@ import {UserAvatar} from './UserAvatar' import {Text} from './text/Text' import {MagnifyingGlassIcon} from '../../lib/icons' import {useStores} from '../../../state' -import {useTheme} from '../../lib/ThemeContext' import {usePalette} from '../../lib/hooks/usePalette' +import {colors} from '../../lib/styles' const HITSLOP = {left: 10, top: 10, right: 10, bottom: 10} const BACK_HITSLOP = {left: 10, top: 10, right: 30, bottom: 10} @@ -26,7 +26,6 @@ export const ViewHeader = observer(function ViewHeader({ subtitle?: string canGoBack?: boolean }) { - const theme = useTheme() const pal = usePalette('default') const store = useStores() const onPressBack = () => { @@ -52,12 +51,12 @@ export const ViewHeader = observer(function ViewHeader({ testID="viewHeaderBackOrMenuBtn" onPress={canGoBack ? onPressBack : onPressMenu} hitSlop={BACK_HITSLOP} - style={canGoBack ? styles.backIcon : styles.backIconWide}> + style={canGoBack ? styles.backBtn : styles.backBtnWide}> {canGoBack ? ( ) : ( @@ -136,15 +132,18 @@ const styles = StyleSheet.create({ fontWeight: 'normal', }, - backIcon: { + backBtn: { width: 30, height: 30, }, - backIconWide: { + backBtnWide: { width: 40, height: 30, marginLeft: 6, }, + backIcon: { + marginTop: 6, + }, btn: { flexDirection: 'row', alignItems: 'center', @@ -154,4 +153,10 @@ const styles = StyleSheet.create({ borderRadius: 20, marginLeft: 4, }, + littleXIcon: { + color: colors.red3, + position: 'absolute', + right: 7, + bottom: 7, + }, }) diff --git a/src/view/com/util/ViewSelector.tsx b/src/view/com/util/ViewSelector.tsx index 9ea7bc740..0dd93ec64 100644 --- a/src/view/com/util/ViewSelector.tsx +++ b/src/view/com/util/ViewSelector.tsx @@ -5,6 +5,7 @@ import {HorzSwipe} from './gestures/HorzSwipe' import {useAnimatedValue} from '../../lib/hooks/useAnimatedValue' import {OnScrollCb} from '../../lib/hooks/useOnMainScroll' import {clamp} from '../../../lib/numbers' +import {s} from '../../lib/styles' const HEADER_ITEM = {_reactKey: '__header__'} const SELECTOR_ITEM = {_reactKey: '__selector__'} @@ -54,7 +55,7 @@ export function ViewSelector({ setSelectedIndex(clamp(index, 0, sections.length)) useEffect(() => { onSelectView?.(selectedIndex) - }, [selectedIndex]) + }, [selectedIndex, onSelectView]) // rendering // = @@ -98,7 +99,7 @@ export function ViewSelector({ onScroll={onScroll} onRefresh={onRefresh} onEndReached={onEndReached} - contentContainerStyle={{paddingBottom: 200}} + contentContainerStyle={s.contentContainer} /> ) diff --git a/src/view/com/util/forms/RadioGroup.tsx b/src/view/com/util/forms/RadioGroup.tsx index 9abc2345f..b33cd9831 100644 --- a/src/view/com/util/forms/RadioGroup.tsx +++ b/src/view/com/util/forms/RadioGroup.tsx @@ -2,6 +2,7 @@ import React, {useState} from 'react' import {View} from 'react-native' import {RadioButton} from './RadioButton' import {ButtonType} from './Button' +import {s} from '../../../lib/styles' export interface RadioGroupItem { label: string @@ -29,7 +30,7 @@ export function RadioGroup({ {items.map((item, i) => ( swipeDistanceThreshold / 4 || Math.abs(gestureState.vx) > swipeVelocityThreshold) ) { - const final = ((gestureState.dx / Math.abs(gestureState.dx)) * -1) | 0 + const final = Math.floor( + (gestureState.dx / Math.abs(gestureState.dx)) * -1, + ) Animated.timing(panX, { toValue: final, duration: 100, @@ -144,7 +147,7 @@ export function HorzSwipe({ }) return ( - + {children} ) diff --git a/src/view/com/util/gestures/SwipeAndZoom.tsx b/src/view/com/util/gestures/SwipeAndZoom.tsx index 881eea094..ee00edab7 100644 --- a/src/view/com/util/gestures/SwipeAndZoom.tsx +++ b/src/view/com/util/gestures/SwipeAndZoom.tsx @@ -9,6 +9,7 @@ import { View, } from 'react-native' import {clamp} from 'lodash' +import {s} from '../../../lib/styles' export enum Dir { None, @@ -294,7 +295,7 @@ export function SwipeAndZoom({ }) return ( - + {children} ) diff --git a/src/view/com/util/images/AutoSizedImage.tsx b/src/view/com/util/images/AutoSizedImage.tsx index a711323a9..648bb957f 100644 --- a/src/view/com/util/images/AutoSizedImage.tsx +++ b/src/view/com/util/images/AutoSizedImage.tsx @@ -47,9 +47,9 @@ export function AutoSizedImage({ setImgInfo({width, height}) } }, - (error: any) => { + (err: any) => { if (!aborted) { - setError(String(error)) + setError(String(err)) } }, ) diff --git a/src/view/com/util/images/ImageLayoutGrid.tsx b/src/view/com/util/images/ImageLayoutGrid.tsx index 5eb5b3c54..8acab7109 100644 --- a/src/view/com/util/images/ImageLayoutGrid.tsx +++ b/src/view/com/util/images/ImageLayoutGrid.tsx @@ -105,7 +105,7 @@ function ImageLayoutGridInner({ onPress?.(1)}> - + onPress?.(2)}> diff --git a/src/view/lib/styles.ts b/src/view/lib/styles.ts index 0b0145ced..7129867e9 100644 --- a/src/view/lib/styles.ts +++ b/src/view/lib/styles.ts @@ -58,6 +58,8 @@ export const gradients = { export const s = StyleSheet.create({ // helpers footerSpacer: {height: 100}, + contentContainer: {paddingBottom: 200}, + border1: {borderWidth: 1}, // font weights fw600: {fontWeight: '600'}, @@ -140,6 +142,7 @@ export const s = StyleSheet.create({ flexCol: {flexDirection: 'column'}, flex1: {flex: 1}, alignCenter: {alignItems: 'center'}, + alignBaseline: {alignItems: 'baseline'}, // position absolute: {position: 'absolute'}, diff --git a/src/view/routes.ts b/src/view/routes.ts index 908036a41..b5cc014ff 100644 --- a/src/view/routes.ts +++ b/src/view/routes.ts @@ -18,7 +18,7 @@ import {Debug} from './screens/Debug' import {Log} from './screens/Log' export type ScreenParams = { - navIdx: [number, number] + navIdx: string params: Record visible: boolean scrollElRef?: MutableRefObject | undefined> diff --git a/src/view/screens/Contacts.tsx b/src/view/screens/Contacts.tsx index a6cc7244e..cba17f285 100644 --- a/src/view/screens/Contacts.tsx +++ b/src/view/screens/Contacts.tsx @@ -17,7 +17,7 @@ export const Contacts = ({navIdx, visible}: ScreenParams) => { if (visible) { store.nav.setTitle(navIdx, 'Contacts') } - }, [store, visible]) + }, [store, visible, navIdx]) const [searchText, onChangeSearchText] = useState('') const inputRef = useRef(null) diff --git a/src/view/screens/Debug.tsx b/src/view/screens/Debug.tsx index f6e2b389c..9365724a0 100644 --- a/src/view/screens/Debug.tsx +++ b/src/view/screens/Debug.tsx @@ -4,6 +4,7 @@ import {ViewHeader} from '../com/util/ViewHeader' import {ThemeProvider} from '../lib/ThemeContext' import {PaletteColorName} from '../lib/ThemeContext' import {usePalette} from '../lib/hooks/usePalette' +import {s} from '../lib/styles' import {Text} from '../com/util/text/Text' import {ViewSelector} from '../com/util/ViewSelector' @@ -48,7 +49,7 @@ function DebugInner({ const renderItem = item => { return ( - + + + {label} @@ -96,7 +97,7 @@ function Heading({label}: {label: string}) { function BaseView() { return ( - + @@ -109,14 +110,14 @@ function BaseView() { - + ) } function ControlsView() { return ( - + @@ -125,15 +126,15 @@ function ControlsView() { - + ) } function ErrorView() { return ( - - + + {}} /> - + - + - + {}} /> - + {}} @@ -171,16 +172,7 @@ function PaletteView({palette}: {palette: PaletteColorName}) { const defaultPal = usePalette('default') const pal = usePalette(palette) return ( - + {palette} colors Light text Link text @@ -197,21 +189,6 @@ function TypographyView() { const pal = usePalette('default') return ( - - 'xxl-thin' lorem ipsum dolor - - - 'xxl' lorem ipsum dolor - - - 'xxl-medium' lorem ipsum dolor - - - 'xxl-bold' lorem ipsum dolor - - - 'xxl-heavy' lorem ipsum dolor - 'xl-thin' lorem ipsum dolor @@ -300,9 +277,6 @@ function TypographyView() { Button - - Overline - ) } @@ -325,16 +299,12 @@ function ButtonsView() { const buttonStyles = {marginRight: 5} return ( - + - + - + - +