Skip to content

Commit 7160907

Browse files
committed
UI and UX tweaks
1 parent 1d4b59d commit 7160907

File tree

10 files changed

+66
-60
lines changed

10 files changed

+66
-60
lines changed

android/app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ android {
139139
applicationId "com.stat_tracker"
140140
minSdkVersion rootProject.ext.minSdkVersion
141141
targetSdkVersion rootProject.ext.targetSdkVersion
142-
versionCode 4
143-
versionName "0.4.1"
142+
versionCode 6
143+
versionName "0.4.2"
144144
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
145145

146146
if (isNewArchitectureEnabled()) {

android/app/src/main/assets/index.android.bundle

+6-6
Large diffs are not rendered by default.

app/components/StatTypeModal.tsx

+26-22
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,15 @@ const ChooseStatModal: React.FC<{
3333
const orphanEntries = entries.filter((el) => !!el.stats.find((st) => st.type === statType.id));
3434

3535
if (orphanEntries.length > 0) {
36-
message += ` You have ${orphanEntries.length} entries that use it! They were made on these dates: `;
37-
const iterations = Math.min(3, orphanEntries.length);
38-
for (let i = 0; i < iterations; i++) {
39-
message += formatIDate(orphanEntries[i].date);
40-
message += i !== iterations - 1 ? ', ' : ' ...';
36+
if (orphanEntries.length === 1)
37+
message += ` You have an entry from ${formatIDate(orphanEntries[0].date)} that uses it!`;
38+
else {
39+
message += ` You have ${orphanEntries.length} entries that use it! They were made on these dates: `;
40+
const iterations = Math.min(3, orphanEntries.length);
41+
for (let i = 0; i < iterations; i++) {
42+
message += formatIDate(orphanEntries[i].date);
43+
message += i !== iterations - 1 ? ', ' : orphanEntries.length > 3 ? ' ...' : '';
44+
}
4145
}
4246
}
4347

@@ -76,15 +80,15 @@ const ChooseStatModal: React.FC<{
7680
}}
7781
>
7882
<View style={GS.modalContainer}>
79-
<ScrollView keyboardShouldPersistTaps="always">
80-
<View style={GS.modalBackground}>
81-
{filteredStatTypes.length === statTypes.length && statTypes.length > 1 && (
82-
<TouchableOpacity onPress={() => setReordering((prevReordering) => !prevReordering)}>
83-
<Text style={{ ...GS.text, marginBottom: 16, textAlign: 'right', color: 'blue' }}>
84-
{reordering ? 'Done' : 'Reorder'}
85-
</Text>
86-
</TouchableOpacity>
87-
)}
83+
<View style={GS.modalBackground}>
84+
{filteredStatTypes.length === statTypes.length && statTypes.length > 1 && (
85+
<TouchableOpacity onPress={() => setReordering((prevReordering) => !prevReordering)}>
86+
<Text style={{ ...GS.text, marginBottom: 16, textAlign: 'right', color: 'blue' }}>
87+
{reordering ? 'Done' : 'Reorder'}
88+
</Text>
89+
</TouchableOpacity>
90+
)}
91+
<ScrollView keyboardShouldPersistTaps="always">
8892
{filteredStatTypes.map((item) => (
8993
<TouchableOpacity onPress={() => submitStatType(item)} key={item.id}>
9094
<View style={GS.smallCard}>
@@ -114,17 +118,17 @@ const ChooseStatModal: React.FC<{
114118
</View>
115119
</TouchableOpacity>
116120
))}
121+
</ScrollView>
117122

118-
<View style={GS.buttonRow}>
119-
<View style={GS.button}>
120-
<Button onPress={onAddStatType} title="New" color="green" />
121-
</View>
122-
<View style={GS.button}>
123-
<Button onPress={onCancel} title="Cancel" color="grey" />
124-
</View>
123+
<View style={GS.buttonRow}>
124+
<View style={GS.button}>
125+
<Button onPress={onAddStatType} title="New" color="green" />
126+
</View>
127+
<View style={GS.button}>
128+
<Button onPress={onCancel} title="Cancel" color="grey" />
125129
</View>
126130
</View>
127-
</ScrollView>
131+
</View>
128132
</View>
129133
</Modal>
130134
);

app/redux/mainSlice.ts

-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ const updatePBs = (state: any, entry: IEntry, mode: 'add' | 'edit' | 'delete') =
203203
}
204204
}
205205
}
206-
console.log(PBsUpdated);
207206

208207
if (PBsUpdated) SM.setData(state.statCategory.id, 'statTypes', state.statTypes);
209208
};

app/screens/AddEditEntry.tsx

+15-9
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,18 @@ const AddEditEntry = ({ navigation, route }) => {
151151

152152
// Delete a stat from the list or edit it (delete from the list, but put values in the inputs)
153153
const deleteEditStat = (stat: IStat, edit = false) => {
154-
setStats((prevStats: IStat[]) => prevStats.filter((el) => el.id !== stat.id));
155-
156-
if (edit) {
157-
const newValues = statTypes.find((el) => el.id === stat.type)?.multipleValues
158-
? [...stat.values, '']
159-
: stat.values;
160-
setStatValues(newValues.map((el) => String(el)));
161-
selectStatType(stat.type);
154+
if (edit && !!statValues.find((el) => el !== '')) {
155+
Alert.alert('Error', 'Please enter your current stat or clear it', [{ text: 'Ok' }]);
156+
} else {
157+
setStats((prevStats: IStat[]) => prevStats.filter((el) => el.id !== stat.id));
158+
159+
if (edit) {
160+
const newValues = statTypes.find((el) => el.id === stat.type)?.multipleValues
161+
? [...stat.values, '']
162+
: stat.values;
163+
setStatValues(newValues.map((el) => String(el)));
164+
selectStatType(stat.type);
165+
}
162166
}
163167
};
164168

@@ -196,11 +200,13 @@ const AddEditEntry = ({ navigation, route }) => {
196200

197201
const onAddStatType = () => {
198202
setStatModalOpen(false);
203+
setStatValues(['']);
199204
navigation.navigate('AddEditStatType');
200205
};
201206

202207
const onEditStatType = (statType: IStatType) => {
203208
setStatModalOpen(false);
209+
setStatValues(['']);
204210
navigation.navigate('AddEditStatType', { statType });
205211
};
206212

@@ -265,7 +271,7 @@ const AddEditEntry = ({ navigation, route }) => {
265271
<TextInput
266272
key={String(index)}
267273
style={GS.input}
268-
placeholder={selectedStatType ? 'Value' : 'Please select stat type first'}
274+
placeholder={selectedStatType ? 'Value' : 'Please select a stat type first'}
269275
placeholderTextColor="grey"
270276
multiline
271277
editable={selectedStatType !== null}

app/shared/GlobalStyles.ts

+9-12
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ export default StyleSheet.create({
77
},
88
modalContainer: {
99
flex: 1,
10-
//alignItems: 'center',
11-
//justifyContent: 'center',
10+
display: 'flex',
11+
justifyContent: 'center',
12+
alignItems: 'center',
1213
},
1314
modalBackground: {
15+
flexDirection: 'column',
16+
justifyContent: 'space-between',
17+
maxHeight: '62%',
1418
width: '80%',
15-
borderRadius: 30,
16-
padding: 20,
17-
marginTop: '40%',
1819
marginBottom: 20,
19-
alignSelf: 'center',
20+
padding: 20,
21+
borderRadius: 30,
22+
backgroundColor: '#fff',
2023
shadowColor: '#000000',
2124
shadowOpacity: 0.5,
2225
elevation: 16,
23-
backgroundColor: '#fff',
24-
flexDirection: 'column',
25-
justifyContent: 'space-between',
2626
},
2727
scrollableArea: {
2828
flex: 1,
@@ -92,9 +92,6 @@ export default StyleSheet.create({
9292
paddingVertical: 10,
9393
borderRadius: 10,
9494
backgroundColor: 'pink',
95-
shadowColor: '#000000',
96-
shadowOpacity: 0.5,
97-
elevation: 5,
9895
},
9996
button: {
10097
flex: 1,

ios/Stat_Tracker.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@
485485
buildSettings = {
486486
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
487487
CLANG_ENABLE_MODULES = YES;
488-
CURRENT_PROJECT_VERSION = 4;
488+
CURRENT_PROJECT_VERSION = 6;
489489
ENABLE_BITCODE = NO;
490490
INFOPLIST_FILE = Stat_Tracker/Info.plist;
491491
LD_RUNPATH_SEARCH_PATHS = (
@@ -511,7 +511,7 @@
511511
buildSettings = {
512512
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
513513
CLANG_ENABLE_MODULES = YES;
514-
CURRENT_PROJECT_VERSION = 4;
514+
CURRENT_PROJECT_VERSION = 6;
515515
INFOPLIST_FILE = Stat_Tracker/Info.plist;
516516
LD_RUNPATH_SEARCH_PATHS = (
517517
"$(inherited)",

ios/Stat_Tracker/Info.plist

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>0.4.1</string>
20+
<string>0.4.2</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
24-
<string>4</string>
24+
<string>6</string>
2525
<key>LSRequiresIPhoneOS</key>
2626
<true />
2727
<key>NSAppTransportSecurity</key>

ios/Stat_TrackerTests/Info.plist

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
<key>CFBundlePackageType</key>
1616
<string>BNDL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.4.1</string>
18+
<string>0.4.2</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>4</string>
22+
<string>6</string>
2323
</dict>
2424
</plist>

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Stat_Tracker",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"private": true,
55
"scripts": {
66
"dev": "alacritty -e yarn emulator & alacritty -e yarn start && sleep 2 & alacritty -e yarn android &",
@@ -15,7 +15,7 @@
1515
"rn-upgrade": "react-native upgrade",
1616
"rn-new-version": "react-native-version --never-amend",
1717
"git-new-version": "VER=$(jq -r .version ./package.json) && git tag -af \"v$VER\" -m \"Version $VER\" && git push -f origin --tags && git tag",
18-
"new-version": "yarn rn-new-version && yarn git-new-version",
18+
"new-version": "yarn rn-new-version && git push && yarn git-new-version",
1919
"test": "jest",
2020
"lint": "eslint ."
2121
},

0 commit comments

Comments
 (0)