-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added team publicity switcher, and changed the timer status code order
- Loading branch information
1 parent
d86276b
commit a3d6d34
Showing
4 changed files
with
93 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
apps/mobile/app/screens/Authenticated/SettingScreen/components/SwitchTeamPublicity.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* eslint-disable react-native/no-color-literals */ | ||
/* eslint-disable react-native/no-inline-styles */ | ||
import React, { FC, useCallback, useEffect, useState } from 'react'; | ||
import { View, Text, StyleSheet } from 'react-native'; | ||
import { observer } from 'mobx-react-lite'; | ||
import { useOrganizationTeam } from '../../../../services/hooks/useOrganization'; | ||
// import { translate } from '../../../../i18n'; | ||
import { limitTextCharaters } from '../../../../helpers/sub-text'; | ||
import { Toggle } from '../../../../components/Toggle'; | ||
import { typography, useAppTheme } from '../../../../theme'; | ||
|
||
interface Props {} | ||
const SwitchTeamPublicity: FC<Props> = observer(() => { | ||
const { colors } = useAppTheme(); | ||
const { onUpdateOrganizationTeam, currentTeam, activeTeam } = useOrganizationTeam(); | ||
|
||
const [isTeamPublic, setIsTeamPublic] = useState<boolean>(activeTeam?.public); | ||
|
||
const toggleSwitch = useCallback(async () => { | ||
await onUpdateOrganizationTeam({ | ||
id: currentTeam?.id, | ||
data: { ...currentTeam, public: !isTeamPublic } | ||
}).then(() => setIsTeamPublic((prev) => !prev)); | ||
}, [isTeamPublic, currentTeam]); | ||
|
||
useEffect(() => { | ||
setIsTeamPublic(activeTeam?.public); | ||
}, [currentTeam]); | ||
return ( | ||
<View style={styles.container}> | ||
<View style={styles.wrapperInfo}> | ||
<Text style={[styles.infoTitle, { color: colors.primary }]}>Team Type</Text> | ||
<Text style={[styles.infoText, { color: colors.tertiary }]}> | ||
{limitTextCharaters({ | ||
text: isTeamPublic ? 'Public Team' : 'Private Team', | ||
numChars: 77 | ||
})} | ||
</Text> | ||
</View> | ||
<Toggle | ||
inputInnerStyle={{ backgroundColor: '#DBD3FA' }} | ||
inputDetailStyle={{ backgroundColor: '#3826A6' }} | ||
onPress={() => toggleSwitch()} | ||
variant="switch" | ||
value={isTeamPublic} | ||
/> | ||
</View> | ||
); | ||
}); | ||
|
||
export default SwitchTeamPublicity; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
alignItems: 'center', | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
marginTop: 32, | ||
width: '100%' | ||
}, | ||
detectWrapper: { | ||
borderRadius: 8, | ||
paddingHorizontal: 13, | ||
paddingVertical: 8 | ||
}, | ||
infoText: { | ||
color: '#938FA4', | ||
fontFamily: typography.primary.medium, | ||
fontSize: 14, | ||
marginTop: 10 | ||
}, | ||
infoTitle: { | ||
fontFamily: typography.primary.semiBold, | ||
fontSize: 16 | ||
}, | ||
toggle: { | ||
height: 40, | ||
right: -10, | ||
top: -10 | ||
}, | ||
wrapperInfo: { | ||
maxWidth: '90%' | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters