Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVA 427 Add log in/out buttons to settings #212

Merged
merged 11 commits into from
Jul 11, 2024
4 changes: 4 additions & 0 deletions .expo/packager-info.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .expo folder is created when an Expo project is started using "expo start" command. It should also automatically add it to .gitignore but think it is a bug in SDK49 that it hasn't done so.

Please delete his folder - you can safely delete it because it does not contain any information that is relevant for other developers working on the project, it is specific to your machine and it's regenerated by expo when you start your app again.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, fixed now too :)

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"expoServerPort": null,
"packagerPort": 19000
}
9 changes: 8 additions & 1 deletion .expo/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{
"urlRandomness": "ZIWJWVY"
"urlRandomness": "ZIWJWVY",
"dev": true,
"minify": false,
"https": false,
"hostType": "lan",
"lanType": "ip",
"scheme": null,
"devClient": false
}
2 changes: 1 addition & 1 deletion src/NativeBase/Components/PrivacyAndTermsLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const PrivacyAndTermsLinks: FC<PrivacyAndTermsLinksProps> = ({ fontSize }) => {
fontSize = fontSize ?? 'xs'

return (
<HStack space="4" justifyContent={'center'}>
<HStack space="4" justifyContent={'space-evenly'}>
<Text>
<Link
_text={{
Expand Down
64 changes: 53 additions & 11 deletions src/NativeBase/Containers/SettingsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@
* See more about dark mode in APP_DEVELOPMENT.md
*/

import { Heading, VStack, Text, ScrollView, useColorMode } from 'native-base'
import React, { useState } from 'react'
import {
Heading,
VStack,
Text,
ScrollView,
useColorMode,
Button,
View,
} from 'native-base'
import { useDispatch, useSelector } from 'react-redux'
import Brand from '@/NativeBase/Components/Brand'
import PrivacyAndTermsLinks from '@/NativeBase/Components/PrivacyAndTermsLinks'
Expand All @@ -27,13 +35,18 @@ import SegmentedPicker, {
SegmentedPickerOption,
} from '../Components/SegmentedPicker'
import { capitaliseFirstLetter } from '@/Utils/Text'
import { useAuth } from '@/Services/auth'
import { navigate } from '@/Navigators/utils'
import { useFeatureFlags } from '@/Services/featureFlags'

const SettingsContainer = () => {
const { colorMode, toggleColorMode } = useColorMode()
const dispatch = useDispatch()

// const onChangeSplash = ({ welcome, show }: Partial<WelcomeState>) => {
// dispatch(changeWelcome({ welcome, show }))
// }

const dataPermissionsState = useSelector(
(state: { permissions: PermissionsState }) => state.permissions.data,
)
Expand All @@ -46,6 +59,7 @@ const SettingsContainer = () => {
// const welcomeState = useSelector(
// (state: { welcome: WelcomeState }) => state.welcome.show,
// )

const [colourModeChoice, setColourModeChoice] = useState<string>(
useSystemColourMode ? 'system' : colorMode ?? 'light',
)
Expand Down Expand Up @@ -87,19 +101,31 @@ const SettingsContainer = () => {
setColourModeChoice(newColourMode)
}

const { authenticated: isLoggedIn, login, logout } = useAuth()

const handleLogin = () => {
navigate('Login', {})
}

const handleLogout = () => {
logout()
}

const featureFlags = useFeatureFlags()

return (
<ScrollView contentContainerStyle={{ flexGrow: 1 }}>
<VStack
height="100%"
justifyContent="space-between"
safeAreaY
space={4}
padding={4}
>
<VStack space="4">
<VStack flex={1} padding={4} space={4}>
<Heading textAlign="center" size="lg" marginTop={8} fontFamily="title">
SETTINGS
</Heading>

<View style={{ marginTop: 48 }}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style is not need here, just marginTop={'48px'} will suffice :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank fixed now too :)

<Brand />
</View>

<VStack space="2">
<VStack space={4} flex={1}>
<VStack space={2}>
<Heading size="xs">Dark mode</Heading>
<SegmentedPicker options={colourModeOptions} />
</VStack>
Expand Down Expand Up @@ -130,9 +156,25 @@ const SettingsContainer = () => {
</Checkbox> */}
</VStack>

<VStack alignItems="center" space="2">
<VStack alignItems="center" space={2} width="100%" paddingBottom={4}>
<Text fontSize="xs">Version {version}</Text>
<PrivacyAndTermsLinks />
{featureFlags.login ? (
Copy link
Collaborator

@PammyLo PammyLo Jun 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The button should align to the bottom regardless of the content, for an example have a look in ProjectFullDetails.tsx, where it is placed outside the ScrollView to achieve this.
  • when the login feature flag is off then it doesn't spread quite over the screen as it does currently and it will probably be released behind the flag initially.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been fixed now, thank you :)

!isLoggedIn ? (
<Button width="90%" onPress={handleLogin}>
Log in
</Button>
) : (
<Button
width="90%"
backgroundColor="white"
_text={{ color: 'error.100', fontWeight: 'bold' }}
onPress={handleLogout}
>
Log out
</Button>
)
) : null}
</VStack>
</VStack>
</ScrollView>
Expand Down
1 change: 1 addition & 0 deletions src/Navigators/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ const MainNavigator = () => {
component={SettingsContainer}
options={{
...bottomTabOptions,
headerShown: false,
}}
/>
</Tab.Navigator>
Expand Down
Loading