-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created the task versions screen (#1784)
* created the task versions screen * rendering the versions * added the bottom sheet and functionalities to add/delete/update * added translations * fixed text when there is 1 version * fixed typo * fixed version name formatting issue, also fixed background in dark mode
- Loading branch information
1 parent
5deb2c2
commit b088bc6
Showing
16 changed files
with
584 additions
and
5 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
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
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
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
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
163 changes: 163 additions & 0 deletions
163
apps/mobile/app/screens/Authenticated/TaskVersionScreen/components/TaskVersionForm.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,163 @@ | ||
/* eslint-disable react-native/no-color-literals */ | ||
/* eslint-disable react-native/no-inline-styles */ | ||
import React, { useEffect, useState } from "react" | ||
import { View, Text, TouchableOpacity, TextInput, StyleSheet, Keyboard } from "react-native" | ||
import { translate } from "../../../../i18n" | ||
import { typography, useAppTheme } from "../../../../theme" | ||
|
||
import { | ||
ITaskVersionCreate, | ||
ITaskVersionItemList, | ||
} from "../../../../services/interfaces/ITaskVersion" | ||
|
||
const TaskVersionForm = ({ | ||
isEdit, | ||
onDismiss, | ||
item, | ||
onCreateVersion, | ||
onUpdateVersion, | ||
}: { | ||
isEdit: boolean | ||
onDismiss: () => unknown | ||
item?: ITaskVersionItemList | ||
onUpdateVersion: (id: string, data: ITaskVersionCreate) => unknown | ||
onCreateVersion: (data: ITaskVersionCreate) => unknown | ||
}) => { | ||
const { colors, dark } = useAppTheme() | ||
const [versionName, setVersionName] = useState<string>(null) | ||
|
||
useEffect(() => { | ||
if (isEdit) { | ||
setVersionName(item.name) | ||
} else { | ||
setVersionName(null) | ||
} | ||
}, [item, isEdit]) | ||
|
||
const handleSubmit = async () => { | ||
if (versionName.trim().length <= 0) { | ||
return | ||
} | ||
|
||
if (isEdit) { | ||
await onUpdateVersion(item?.id, { | ||
name: versionName, | ||
}) | ||
} else { | ||
await onCreateVersion({ | ||
name: versionName, | ||
color: "#FFFFFF", | ||
}) | ||
} | ||
|
||
setVersionName(null) | ||
onDismiss() | ||
} | ||
|
||
return ( | ||
<View | ||
style={{ | ||
backgroundColor: colors.background, | ||
paddingHorizontal: 25, | ||
paddingTop: 26, | ||
paddingBottom: 40, | ||
height: 452, | ||
}} | ||
> | ||
<Text style={{ ...styles.formTitle, color: colors.primary }}> | ||
{translate("settingScreen.versionScreen.createNewVersionText")} | ||
</Text> | ||
<TextInput | ||
style={{ ...styles.versionNameInput, color: colors.primary }} | ||
placeholderTextColor={"#7B8089"} | ||
placeholder={translate("settingScreen.versionScreen.versionNamePlaceholder")} | ||
defaultValue={versionName} | ||
onChangeText={(text) => setVersionName(text)} | ||
/> | ||
|
||
<View style={styles.wrapButtons}> | ||
<TouchableOpacity | ||
style={styles.cancelBtn} | ||
onPress={() => { | ||
onDismiss() | ||
Keyboard.dismiss() | ||
}} | ||
> | ||
<Text style={styles.cancelTxt}> | ||
{translate("settingScreen.versionScreen.cancelButtonText")} | ||
</Text> | ||
</TouchableOpacity> | ||
<TouchableOpacity | ||
style={{ | ||
...styles.createBtn, | ||
backgroundColor: dark ? "#6755C9" : "#3826A6", | ||
opacity: !versionName ? 0.2 : 1, | ||
}} | ||
onPress={() => { | ||
if (versionName) { | ||
handleSubmit().finally(() => Keyboard.dismiss()) | ||
} | ||
}} | ||
> | ||
<Text style={styles.createTxt}> | ||
{isEdit | ||
? translate("settingScreen.versionScreen.updateButtonText") | ||
: translate("settingScreen.versionScreen.createButtonText")} | ||
</Text> | ||
</TouchableOpacity> | ||
</View> | ||
</View> | ||
) | ||
} | ||
|
||
export default TaskVersionForm | ||
|
||
const styles = StyleSheet.create({ | ||
cancelBtn: { | ||
alignItems: "center", | ||
backgroundColor: "#E6E6E9", | ||
borderRadius: 12, | ||
height: 57, | ||
justifyContent: "center", | ||
width: "48%", | ||
}, | ||
cancelTxt: { | ||
color: "#1A1C1E", | ||
fontFamily: typography.primary.semiBold, | ||
fontSize: 18, | ||
}, | ||
createBtn: { | ||
alignItems: "center", | ||
backgroundColor: "#3826A6", | ||
borderRadius: 12, | ||
height: 57, | ||
justifyContent: "center", | ||
width: "48%", | ||
}, | ||
createTxt: { | ||
color: "#FFF", | ||
fontFamily: typography.primary.semiBold, | ||
fontSize: 18, | ||
}, | ||
formTitle: { | ||
color: "#1A1C1E", | ||
fontFamily: typography.primary.semiBold, | ||
fontSize: 24, | ||
}, | ||
versionNameInput: { | ||
alignItems: "center", | ||
borderColor: "#DCE4E8", | ||
borderRadius: 12, | ||
borderWidth: 1, | ||
height: 57, | ||
marginTop: 16, | ||
paddingHorizontal: 18, | ||
width: "100%", | ||
}, | ||
wrapButtons: { | ||
flexDirection: "row", | ||
justifyContent: "space-between", | ||
marginTop: 40, | ||
width: "100%", | ||
}, | ||
}) |
Oops, something went wrong.