Skip to content

Commit 3ac236d

Browse files
FIX: Reset ActivityPlayer state and standardize icons using lucide-react (#191)
2 parents bf6f3c5 + 1c76ea0 commit 3ac236d

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

app/src/components/EditActivityButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function EditActivityButton({ activity, updateActivity }: AlertIconDialog
4545
const newActivity: Activity = {
4646
id: activity.id,
4747
name: values.name,
48-
activityType: activity.activityType,
48+
type: activity.type,
4949
duration: values.duration,
5050
energy: values.energy,
5151
favorite: activity.favorite

app/src/screens/ActivityPlayer.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ export const ActivityPlayer: React.FC = () => {
148148
}
149149

150150
const finishSession = () => {
151+
setIsPlaying(false);
152+
setIsFinished(false);
153+
setIsReloading(false);
154+
setCurrentStep(0);
151155
navigate(Stacks.Auth, {
152156
screen: Screens.Feedback,
153157
params: { activityId: params?.activityId }
@@ -156,6 +160,10 @@ export const ActivityPlayer: React.FC = () => {
156160

157161
const exitActivity = async () => {
158162
await sound.current.unloadAsync();
163+
setIsPlaying(false);
164+
setIsFinished(false);
165+
setIsReloading(false);
166+
setCurrentStep(0);
159167
navigate(Stacks.Auth, { screen: Screens.Home });
160168
};
161169

app/src/screens/Feedback.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export const Feedback: React.FC = () => {
154154
/>
155155

156156
<View className='flex flex-row justify-end mt-4'>
157-
<Button className='' onPress={handleSubmit}>
157+
<Button className='' onPress={handleSubmit} disabled={message.length === 0}>
158158
<Text className='text-primary-foreground'>Submit</Text>
159159
</Button>
160160
</View>

app/src/screens/History.tsx

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
import { useNavigation } from '@react-navigation/native';
22
import { Text } from '@shadcn/components';
3+
import { iconWithClassName } from '@shadcn/icons/iconWithClassName';
34
import { Collections, Screens, Stacks, fireAuth, fireStore } from '@src/constants';
45
import type { HistoryActivity } from '@src/types';
56
import type { AppNavigation } from '@src/types';
67
import { collection, doc, getDocs, updateDoc } from 'firebase/firestore';
7-
import { UserIcon } from 'lucide-react-native';
8+
import { Brain, Heart, House, PenLine, RefreshCw, UserIcon } from 'lucide-react-native';
89
import React, { useEffect } from 'react';
910
import { useAuthState } from 'react-firebase-hooks/auth';
1011
import { Image, ScrollView, TouchableOpacity, View } from 'react-native';
11-
import FeatherIcon from 'react-native-vector-icons/Feather';
12-
import type { IconProps } from 'react-native-vector-icons/Icon';
13-
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
12+
13+
iconWithClassName(PenLine);
14+
iconWithClassName(RefreshCw);
1415

1516
export const History: React.FC = () => {
1617
const { navigate } = useNavigation<AppNavigation>();
1718
const [user] = useAuthState(fireAuth);
1819
const [activeTab, setActiveTab] = React.useState<'all' | 'favorites'>('all');
19-
const [items, setItems] = React.useState([] as HistoryActivity[]);
20-
21-
const MCIIcon = MaterialCommunityIcons as unknown as React.FC<IconProps>;
22-
const FeatherIconCasted = FeatherIcon as unknown as React.FC<IconProps>;
20+
const [items, setItems] = React.useState<HistoryActivity[]>([]);
2321

2422
const fetchFavoriteActivities = async () => {
2523
if (!user) {
@@ -104,11 +102,7 @@ export const History: React.FC = () => {
104102
};
105103

106104
// Decide which items to show based on activeTab
107-
const itemsToShow =
108-
activeTab === 'all' ? items : items.filter((item) => item.isFavourite === true);
109-
110-
// Icon color
111-
const iconColor = '#620674';
105+
const itemsToShow = activeTab === 'all' ? items : items.filter((item) => item.isFavourite);
112106

113107
return (
114108
<View className='flex flex-1 flex-col px-6 gap-y-4'>
@@ -125,7 +119,7 @@ export const History: React.FC = () => {
125119
</View>
126120

127121
<TouchableOpacity onPress={onHomeBtnPressed} className='ml-auto'>
128-
<FeatherIconCasted name='home' size={27} color='#620674' />
122+
<House size={27} className='text-primary' />
129123
</TouchableOpacity>
130124
</View>
131125

@@ -179,23 +173,22 @@ export const History: React.FC = () => {
179173
<View className='flex-row'>
180174
<TouchableOpacity className='m-2' onPress={() => handleToggleFavourite(item.id)}>
181175
{/* If isFavourite = true => heart (filled), else => heart-outline */}
182-
<MCIIcon
183-
name={item.isFavourite ? 'heart' : 'heart-outline'}
176+
<Heart
184177
size={20}
185-
color={iconColor}
178+
className={`text-primary ${item.isFavourite ? 'fill-primary' : ''}`}
186179
/>
187180
</TouchableOpacity>
188181
<TouchableOpacity className='m-2'>
189-
<MCIIcon name='brain' size={20} color={iconColor} />
182+
<Brain size={20} className='text-primary' />
190183
</TouchableOpacity>
191184
</View>
192185
{/* Bottom row */}
193186
<View className='flex-row'>
194187
<TouchableOpacity className='m-2'>
195-
<FeatherIconCasted name='edit-3' size={20} color={iconColor} />
188+
<PenLine size={20} className='text-primary' />
196189
</TouchableOpacity>
197190
<TouchableOpacity className='m-2' onPress={() => replayActivity(item.id)}>
198-
<FeatherIconCasted name='refresh-cw' size={20} color={iconColor} />
191+
<RefreshCw size={20} className='text-primary' />
199192
</TouchableOpacity>
200193
</View>
201194
</View>

0 commit comments

Comments
 (0)