Skip to content

Commit

Permalink
Merge branch 'main' into frankreed/submit_drill_spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankreedX committed Aug 16, 2024
2 parents a8b0181 + 2800846 commit 6113ec8
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 136 deletions.
276 changes: 142 additions & 134 deletions app/content/profile/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MaterialIcons } from "@expo/vector-icons";
import { KeyboardAvoiderScrollView } from "@good-react-native/keyboard-avoider";
import {
BottomSheetModalProvider,
BottomSheetScrollView,
Expand Down Expand Up @@ -320,150 +321,157 @@ function Index() {
}}
>
<BottomSheetScrollView
contentContainerStyle={styles.modalContent}
keyboardDismissMode="interactive"
keyboardShouldPersistTaps="handled"
>
{/* Profile Picture */}
<TouchableOpacity
onPress={async () => {
try {
await handleImageUpload(
setImageUploading,
showSnackBar,
getPfpName(currentTeamId, userId),
userRef,
profilePicSize,
profilePicSize,
);
await invalidateMultipleKeys(queryClient, [["userInfo"]]);
} catch (e) {
console.log(e);
showDialog("Error", getErrorString(e));
}
}}
>
<View style={styles.profilePictureContainer}>
{imageUploading ? (
<ActivityIndicator
animating={imageUploading}
size="large"
color={themeColors.accent}
style={styles.activityIndicator}
/>
) : (
<ProfilePicture
userInfo={userData}
style={styles.profilePicture}
/>
)}
<View style={styles.penIconContainer}>
<MaterialIcons name="edit" size={24} color="black" />
</View>
</View>
</TouchableOpacity>
{/* Display Name */}
<Text
style={{
fontSize: 20,
marginBottom: 10,
fontWeight: "bold",
}}
>
{userData.name}
</Text>
<KeyboardAvoiderScrollView>
<View style={styles.modalContent}>
{/* Profile Picture */}
<TouchableOpacity
onPress={async () => {
try {
await handleImageUpload(
setImageUploading,
showSnackBar,
getPfpName(currentTeamId, userId),
userRef,
profilePicSize,
profilePicSize,
);
await invalidateMultipleKeys(queryClient, [["userInfo"]]);
} catch (e) {
console.log(e);
showDialog("Error", getErrorString(e));
}
}}
>
<View style={styles.profilePictureContainer}>
{imageUploading ? (
<ActivityIndicator
animating={imageUploading}
size="large"
color={themeColors.accent}
style={styles.activityIndicator}
/>
) : (
<ProfilePicture
userInfo={userData}
style={styles.profilePicture}
/>
)}
<View style={styles.penIconContainer}>
<MaterialIcons name="edit" size={24} color="black" />
</View>
</View>
</TouchableOpacity>
{/* Display Name */}
<Text
style={{
fontSize: 20,
marginBottom: 10,
fontWeight: "bold",
}}
>
{userData.name}
</Text>

{/* Display Email */}
<View style={styles.emailContainer}>
<Text style={styles.emailText}>{email}</Text>
</View>

{/* Name Update input field */}
<View style={{ width: "80%", marginBottom: 10 }}>
<Text style={styles.changePasswordButton}>Update your name</Text>
</View>
<BottomSheetTextInput
style={styles.input}
value={newName}
onChangeText={(text) => setNewName(text)}
placeholder="Update your name"
/>

{/* Change Password Button */}
<View
style={{
marginBottom: 20, // Increase margin bottom for more spacing
flexDirection: "row",
alignItems: "center",
width: "80%",
justifyContent: "space-between",
}}
>
<Text style={styles.changePasswordButton}>Change Password</Text>
<Switch
value={passwordInputVisible}
onValueChange={(newValue) => {
resetForm();
setPasswordInputVisible(newValue);
}}
theme={{
colors: {
primary: themeColors.accent,
},
}}
/>
</View>
{/* Display Email */}
<View style={styles.emailContainer}>
<Text style={styles.emailText}>{email}</Text>
</View>

{/* Password Input Field */}
{passwordInputVisible && (
<>
<BottomSheetTextInput
style={styles.input}
value={currentPassword}
onChangeText={setCurrentPassword}
placeholder="Enter your current password"
secureTextEntry={true}
// to get rid of ios password suggestions
// More info on onChangeText + ios password suggestions bug: https://github.com/facebook/react-native/issues/21261
// Workaround ("oneTimeCode" textContentType): https://stackoverflow.com/a/68658035
textContentType="oneTimeCode"
/>
<BottomSheetTextInput
style={styles.input}
value={newPassword}
onChangeText={setNewPassword}
placeholder="Enter your new password"
secureTextEntry={true}
textContentType="newPassword"
/>
{/* Name Update input field */}
<View style={{ width: "80%", marginBottom: 10 }}>
<Text style={styles.changePasswordButton}>
Update your name
</Text>
</View>
<BottomSheetTextInput
style={styles.input}
value={newPasswordCheck}
onChangeText={setNewPasswordCheck}
placeholder="Confirm your new password"
secureTextEntry={true}
textContentType="newPassword"
value={newName}
onChangeText={(text) => setNewName(text)}
placeholder="Update your name"
/>
</>
)}

{/* Save Button */}
<Button
style={styles.saveChangesButton}
onPress={handleUpdate}
textColor={themeColors.highlight}
labelStyle={{
fontWeight: "bold",
}}
loading={updateLoading}
>
Update
</Button>
{/* Change Password Button */}
<View
style={{
marginBottom: 20, // Increase margin bottom for more spacing
flexDirection: "row",
alignItems: "center",
width: "80%",
justifyContent: "space-between",
}}
>
<Text style={styles.changePasswordButton}>
Change Password
</Text>
<Switch
value={passwordInputVisible}
onValueChange={(newValue) => {
resetForm();
setPasswordInputVisible(newValue);
}}
theme={{
colors: {
primary: themeColors.accent,
},
}}
/>
</View>

{/* Password Input Field */}
{passwordInputVisible && (
<>
<BottomSheetTextInput
style={styles.input}
value={currentPassword}
onChangeText={setCurrentPassword}
placeholder="Enter your current password"
secureTextEntry={true}
// to get rid of ios password suggestions
// More info on onChangeText + ios password suggestions bug: https://github.com/facebook/react-native/issues/21261
// Workaround ("oneTimeCode" textContentType): https://stackoverflow.com/a/68658035
textContentType="oneTimeCode"
/>
<BottomSheetTextInput
style={styles.input}
value={newPassword}
onChangeText={setNewPassword}
placeholder="Enter your new password"
secureTextEntry={true}
textContentType="newPassword"
/>
<BottomSheetTextInput
style={styles.input}
value={newPasswordCheck}
onChangeText={setNewPasswordCheck}
placeholder="Confirm your new password"
secureTextEntry={true}
textContentType="newPassword"
/>
</>
)}

{/* Save Button */}
<Button
style={styles.saveChangesButton}
onPress={handleUpdate}
textColor={themeColors.highlight}
labelStyle={{
fontWeight: "bold",
}}
loading={updateLoading}
>
Update
</Button>

{/* Sign Out Button */}
<Pressable onPress={handleSignOut}>
<Text style={styles.signOutButton}>Sign Out</Text>
</Pressable>
{/* Sign Out Button */}
<Pressable onPress={handleSignOut}>
<Text style={styles.signOutButton}>Sign Out</Text>
</Pressable>
</View>
</KeyboardAvoiderScrollView>
</BottomSheetScrollView>
</BottomSheetWrapper>
{uniqueDrills.length > 0 && userData.role === "player" ? (
Expand Down
25 changes: 23 additions & 2 deletions app/content/team/users/[user]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import { useLocalSearchParams, useNavigation } from "expo-router";
import { doc, setDoc, updateDoc } from "firebase/firestore";
import { useState } from "react";
import { FlatList, View } from "react-native";
import { Appbar, Divider, Menu, SegmentedButtons } from "react-native-paper";
import {
ActivityIndicator,
Appbar,
Divider,
Menu,
SegmentedButtons,
Text,
} from "react-native-paper";
import { SafeAreaView } from "react-native-safe-area-context";
import { themeColors } from "~/Constants";
import { getErrorString } from "~/Utility";
Expand Down Expand Up @@ -71,6 +78,8 @@ function Index() {
const hideBanDialog = () => setBanDialogVisible(false);
const [banLoading, setBanLoading] = useState(false);

const [promoteLoading, setPromoteLoading] = useState(false);

const { showDialog, showSnackBar } = useAlertContext();

const { currentUserId, currentTeamId } = useAuthContext();
Expand Down Expand Up @@ -246,6 +255,7 @@ function Index() {
}
onPress={async () => {
try {
setPromoteLoading(true);
await changeRole(
currentTeamId,
userId,
Expand All @@ -258,8 +268,19 @@ function Index() {
console.log(e);
showDialog("Error", getErrorString(e));
}
setPromoteLoading(false);
}}
title={userInfo.role === "player" ? "Promote" : "Demote"}
title={
<>
{promoteLoading ? (
<ActivityIndicator color={"#1C1B1F"} />
) : (
<Text>
{userInfo.role === "player" ? "Promote" : "Demote"}
</Text>
)}
</>
}
/>
<Divider />
<Menu.Item
Expand Down
Loading

0 comments on commit 6113ec8

Please sign in to comment.