Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mobile): task management bb-445 #577

Merged
merged 19 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1e9b5d2
feat: add disabled switch prop bb-445
Olha-Katran Sep 25, 2024
3364257
feat: change style bb-445
Olha-Katran Sep 25, 2024
4bb3332
feat: add task-background png bb-445
Olha-Katran Sep 25, 2024
4b03fc2
feat: add task empty state, add background bb-445
Olha-Katran Sep 25, 2024
244298c
feat: add background bb-445
Olha-Katran Sep 25, 2024
2dd7edb
feat: add export image-background component bb-445
Olha-Katran Sep 25, 2024
77b7ab7
feat: delete unnecessary task svg bb-445
Olha-Katran Sep 25, 2024
c2b7445
Merge branch 'main' into 445-feat-task-management
Olha-Katran Sep 25, 2024
088afd4
feat: pass isDisabled to touchable-opacity bb-445
Olha-Katran Sep 26, 2024
38d9969
feat(mobile): resolved merge conflict, optimized tasks bg size bb-445
Shcracoziabra Sep 27, 2024
3f63662
refactor(mobile): refactored Tasks screen bb-445
Shcracoziabra Sep 27, 2024
8136cab
Merge branch 'main' into 445-feat-task-management
Shcracoziabra Sep 27, 2024
46250a2
refactor(mobile): used item.id in handleKeyExtractor bb-445
Shcracoziabra Sep 27, 2024
f1a3242
Merge branch '445-feat-task-management' of https://github.com/BinaryS…
Shcracoziabra Sep 27, 2024
6defac3
refactor(mobile): added getActiveAndExpiredTasks helper bb-445
Shcracoziabra Sep 27, 2024
3f38da0
refactor(mobile): updated tasks state and actions, used useFocusEffec…
Shcracoziabra Sep 27, 2024
dd8030f
Merge branch 'main' into 445-feat-task-management
Shcracoziabra Sep 27, 2024
12eb2d9
feat(mobile): resolved merge conflict bb-445
Shcracoziabra Sep 27, 2024
fb02cb1
fix(mobile): removed unused state bb-445
revenets Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added apps/mobile/src/assets/images/background.png
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer svg

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/mobile/src/libs/components/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export { default as MaskedView } from "@react-native-masked-view/masked-view";
export {
ActivityIndicator,
Image,
ImageBackground,
KeyboardAvoidingView,
Pressable,
ScrollView,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@ import { styles } from "./style";

type PageSwitcherProperties = {
activeTab: string;
isDisabled?: boolean;
onTabChange: (tab: string) => void;
style?: StyleProp<ViewStyle>;
tabs: string[];
};

const PageSwitcher: React.FC<PageSwitcherProperties> = ({
activeTab,
isDisabled = false,
onTabChange,
style,
tabs,
}) => {
const handleTabPress = useCallback(
(tab: string): void => {
onTabChange(tab);
if (!isDisabled) {
Olha-Katran marked this conversation as resolved.
Show resolved Hide resolved
onTabChange(tab);
}
},
[onTabChange],
[onTabChange, isDisabled],
);

const handlePress = (tab: string): (() => void) => {
Expand All @@ -46,6 +50,7 @@ const PageSwitcher: React.FC<PageSwitcherProperties> = ({
globalStyles.pv8,
styles.tab,
isActive ? styles.activeTab : styles.inactiveTab,
isDisabled && styles.disabledTab,
]}
>
<Text
Expand Down
3 changes: 3 additions & 0 deletions apps/mobile/src/libs/components/page-switcher/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const styles = StyleSheet.create({
backgroundColor: BaseColor.EXTRA_LIGHT_GRAY,
borderRadius: 30,
},
disabledTab: {
opacity: 0.5,
},
inactive: {
color: BaseColor.GRAY,
},
Expand Down
1 change: 1 addition & 0 deletions apps/mobile/src/libs/components/task-card/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const styles = StyleSheet.create({
borderTopWidth: 1,
},
container: {
backgroundColor: BaseColor.BG_WHITE,
borderColor: BaseColor.LIGHT_GRAY,
borderRadius: 16,
borderWidth: 1,
Expand Down
10 changes: 10 additions & 0 deletions apps/mobile/src/screens/tasks/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@ import { StyleSheet } from "react-native";
import { BaseColor } from "~/libs/enums/enums";

const styles = StyleSheet.create({
background: {
backgroundColor: "rgba(255, 255, 255, 0.9)",
},
backgroundContainer: {
marginVertical: -10,
},
container: {
backgroundColor: BaseColor.BG_WHITE,
},
empty: {
opacity: 1,
textAlign: "center",
},
switch: {
maxWidth: "50%",
},
Expand Down
69 changes: 57 additions & 12 deletions apps/mobile/src/screens/tasks/tasks.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";

import {
ImageBackground,
LoaderWrapper,
PageSwitcher,
ScreenWrapper,
Expand All @@ -9,7 +10,7 @@ import {
Text,
View,
} from "~/libs/components/components";
import { DataStatus } from "~/libs/enums/enums";
import { DataStatus, NumericalValue } from "~/libs/enums/enums";
import {
useAppDispatch,
useAppSelector,
Expand All @@ -18,7 +19,8 @@ import {
useState,
} from "~/libs/hooks/hooks";
import { globalStyles } from "~/libs/styles/styles";
import { type ValueOf } from "~/libs/types/types";
import { type ImageSourcePropType, type ValueOf } from "~/libs/types/types";
import { type TaskDto } from "~/packages/tasks/tasks";
import { type UserDto } from "~/packages/users/users";
import { actions as taskActions } from "~/slices/task/task";
import { actions as userActions } from "~/slices/users/users";
Expand All @@ -36,6 +38,15 @@ const Tasks: React.FC = () => {
TasksMode.CURRENT,
);

const currentTasks: TaskDto[] = tasks.filter(
(task) => task.status === TaskStatus.CURRENT,
);
const pastTasks: TaskDto[] = tasks.filter(
(task) => task.status === TaskStatus.COMPLETED,
);
const isCurrentEmpty = currentTasks.length === NumericalValue.ZERO;
const isPastEmpty = pastTasks.length === NumericalValue.ZERO;

Shcracoziabra marked this conversation as resolved.
Show resolved Hide resolved
useEffect(() => {
void dispatch(
userActions.getById({ id: (authenticatedUser as UserDto).id }),
Expand Down Expand Up @@ -104,16 +115,50 @@ const Tasks: React.FC = () => {
tabs={[TaskTab.ACTIVE, TaskTab.PAST]}
/>
</View>
<ScrollView>
{tasks.map((task) => (
<TaskCard
key={task.id}
onComplete={handleComplete}
onSkip={handleSkip}
task={task}
/>
))}
</ScrollView>
<ImageBackground
resizeMode="cover"
source={
require("~/assets/images/background.png") as ImageSourcePropType
}
style={[globalStyles.flex1, styles.backgroundContainer]}
>
<View style={[globalStyles.flex1, styles.background]}>
{(isCurrentEmpty && mode === TasksMode.CURRENT) ||
(isPastEmpty && mode === TasksMode.PAST) ? (
<View
style={[
globalStyles.flex1,
globalStyles.alignItemsCenter,
globalStyles.justifyContentCenter,
]}
>
<Text
preset="subheading"
style={[globalStyles.ph32, styles.empty]}
weight="bold"
>
{mode === TasksMode.CURRENT
? "You don't have any active tasks"
: "You don't have any completed tasks"}
</Text>
</View>
Shcracoziabra marked this conversation as resolved.
Show resolved Hide resolved
) : (
<ScrollView
Olha-Katran marked this conversation as resolved.
Show resolved Hide resolved
showsVerticalScrollIndicator={false}
style={globalStyles.mt8}
>
{tasks.map((task) => (
<TaskCard
key={task.id}
onComplete={handleComplete}
onSkip={handleSkip}
task={task}
/>
))}
</ScrollView>
)}
</View>
</ImageBackground>
</LoaderWrapper>
</ScreenWrapper>
);
Expand Down
Loading