From ba22cc7604cf86d825a5b129324f64cef8dd9068 Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Sun, 22 Aug 2021 18:28:11 +0900 Subject: [PATCH] only allow settings (to add server) on first run --- app/navigation/BottomTabBar.tsx | 62 ++++++++++++++------------- app/navigation/BottomTabNavigator.tsx | 10 +++-- app/screens/SplashPage.tsx | 6 +-- app/state/settings.ts | 2 + 4 files changed, 45 insertions(+), 35 deletions(-) diff --git a/app/navigation/BottomTabBar.tsx b/app/navigation/BottomTabBar.tsx index aefec06..e867ea2 100644 --- a/app/navigation/BottomTabBar.tsx +++ b/app/navigation/BottomTabBar.tsx @@ -1,5 +1,7 @@ import NowPlayingBar from '@app/components/NowPlayingBar' import PressableOpacity from '@app/components/PressableOpacity' +import { selectSettings } from '@app/state/settings' +import { useStore } from '@app/state/store' import colors from '@app/styles/colors' import dimensions from '@app/styles/dimensions' import font from '@app/styles/font' @@ -18,6 +20,10 @@ const BottomTabButton = React.memo<{ icon: OutlineFillIcon navigation: NavigationHelpers }>(({ routeKey, label, name, isFocused, icon, navigation }) => { + const firstRun = useStore(selectSettings.firstRun) + + const disabled = firstRun && name !== 'settings' + const onPress = () => { const event = navigation.emit({ type: 'tabPress', @@ -40,43 +46,41 @@ const BottomTabButton = React.memo<{ const textStyle = [styles.text, { color: focusColor }] return ( - + {label} ) }) -const BottomTabBar: React.FC = ({ state, descriptors, navigation }) => { - return ( - - - - {state.routes.map((route, index) => { - const { options } = descriptors[route.key] as any - const label = - options.tabBarLabel !== undefined - ? (options.tabBarLabel as string) - : options.title !== undefined - ? options.title - : route.name +const BottomTabBar: React.FC = ({ state, descriptors, navigation }) => ( + + + + {state.routes.map((route, index) => { + const { options } = descriptors[route.key] as any + const label = + options.tabBarLabel !== undefined + ? (options.tabBarLabel as string) + : options.title !== undefined + ? options.title + : route.name - return ( - - ) - })} - + return ( + + ) + })} - ) -} + +) const styles = StyleSheet.create({ container: { diff --git a/app/navigation/BottomTabNavigator.tsx b/app/navigation/BottomTabNavigator.tsx index 556e6a6..70bc324 100644 --- a/app/navigation/BottomTabNavigator.tsx +++ b/app/navigation/BottomTabNavigator.tsx @@ -1,11 +1,14 @@ import BottomTabBar from '@app/navigation/BottomTabBar' import LibraryTopTabNavigator from '@app/navigation/LibraryTopTabNavigator' -import SongListView from '@app/screens/SongListView' import ArtistView from '@app/screens/ArtistView' import Home from '@app/screens/Home' import Search from '@app/screens/Search' +import SearchResultsView from '@app/screens/SearchResultsView' import ServerView from '@app/screens/ServerView' import SettingsView from '@app/screens/Settings' +import SongListView from '@app/screens/SongListView' +import { selectSettings } from '@app/state/settings' +import { useStore } from '@app/state/store' import colors from '@app/styles/colors' import font from '@app/styles/font' import { BottomTabNavigationProp, createBottomTabNavigator } from '@react-navigation/bottom-tabs' @@ -13,7 +16,6 @@ import { RouteProp, StackActions } from '@react-navigation/native' import React, { useEffect } from 'react' import { StyleSheet } from 'react-native' import { createNativeStackNavigator, NativeStackNavigationProp } from 'react-native-screens/native-stack' -import SearchResultsView from '@app/screens/SearchResultsView' type TabStackParamList = { main: undefined @@ -155,8 +157,10 @@ const SettingsTab = () => { const Tab = createBottomTabNavigator() const BottomTabNavigator = () => { + const firstRun = useStore(selectSettings.firstRun) + return ( - + diff --git a/app/screens/SplashPage.tsx b/app/screens/SplashPage.tsx index 322e33f..385c1b3 100644 --- a/app/screens/SplashPage.tsx +++ b/app/screens/SplashPage.tsx @@ -82,14 +82,14 @@ const styles = StyleSheet.create({ alignItems: 'center', }, image: { - height: 140, - width: 140, + height: 150, + width: 150, marginBottom: -10, tintColor: colors.accent, }, text: { fontFamily: font.bold, - fontSize: 50, + fontSize: 31, color: colors.text.primary, }, }) diff --git a/app/state/settings.ts b/app/state/settings.ts index 5173e34..bb7edb0 100644 --- a/app/state/settings.ts +++ b/app/state/settings.ts @@ -30,6 +30,8 @@ export type SettingsSlice = { export const selectSettings = { client: (state: SettingsSlice) => state.client, + firstRun: (state: SettingsSlice) => state.settings.servers.length === 0, + activeServer: (state: SettingsSlice) => state.settings.servers.find(s => s.id === state.settings.activeServer), setActiveServer: (state: SettingsSlice) => state.setActiveServer,