Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Swipe #275

Open
wants to merge 48 commits into
base: development
Choose a base branch
from
Open

Swipe #275

Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
c44636d
refactor: streamline ListItem component and clean up types and styles
Sacha338 Jun 18, 2024
091700a
refactor: update NativeItem component types and streamline styles
Sacha338 Jun 18, 2024
52ae70d
refactor: improve typings and add missing props in NativeItem component
Sacha338 Jun 18, 2024
941d1e2
refactor: update NativeList.ios.tsx for improved prop typing and memo…
Sacha338 Jun 18, 2024
1c8b53a
feat: Enhanced NativeList component with sectionProps and sideBar option
Sacha338 Jun 18, 2024
b0324c8
refactor: update PapillonButton component styles and props
Sacha338 Jun 18, 2024
77d9fd8
feat: add size prop and update styles in PapillonIcon component
Sacha338 Jun 18, 2024
37684cb
fix: add missing plain prop in PapillonList component
Sacha338 Jun 18, 2024
63e243c
feat: make subtitle optional and update icon prop in PapillonLoading …
Sacha338 Jun 18, 2024
f0d1f42
refactor: refactor fetch functions to use async/await in LoginFlow.js
Sacha338 Jun 18, 2024
89edb47
fix(bagReminder): correct type casting and null checks for timetable …
Sacha338 Jun 19, 2024
a74360e
fix(grades): correct type casting and handle null values in grade pro…
Sacha338 Jun 19, 2024
35f2bfd
Refactor: Add explicit types and improve readability in Homework noti…
Sacha338 Jun 19, 2024
ad776b9
Enhancement: Add null check for dataInstance in Lessons.ts and improv…
Sacha338 Jun 19, 2024
3b96f92
Refactor: Add typings and update date comparison in SelfReminder.ts
Sacha338 Jun 19, 2024
1acf59a
Refactor: Add classroom property to PapillonLesson and sort timetable…
Sacha338 Jun 19, 2024
348eb60
Refactor: Add observations property to PapillonVieScolaire and handle…
Sacha338 Jun 19, 2024
246c83f
style: add semicolons for consistent code formatting
Sacha338 Jun 19, 2024
0816b96
fix: handle undefined grade values with defaults
Sacha338 Jun 19, 2024
1906cb0
Update index.ts
Sacha338 Jun 19, 2024
83cd740
feat(timetable): add classroom and num properties to PapillonLesson i…
Sacha338 Jun 19, 2024
7e7eb98
fix(grades): handle undefined grade values in getGradeState
Sacha338 Jun 19, 2024
e08d856
feat(timetable): add classroom property to PapillonLesson
Sacha338 Jun 19, 2024
74d2360
Refactor: Update type definitions for PapillonVieScolaire interfaces
Sacha338 Jun 19, 2024
f56f570
Refactor: Simplify AlertBottomSheet component props handling and anim…
Sacha338 Jun 19, 2024
7f82441
Refactor TimeSeparator to TypeScript with Props Interface
Sacha338 Jun 19, 2024
0d6f65f
Refactor NextCours component to improve performance and UI details ha…
Sacha338 Jun 19, 2024
9f2afc9
refactor: clean up and type view options in AppStack
Sacha338 Jun 19, 2024
72326fe
refactor: add type assertion and platform import in AuthStack
Sacha338 Jun 19, 2024
1ba11dd
refactor: optimize screenOptions for InsetSettings and add Platform i…
Sacha338 Jun 19, 2024
963f447
feat(TabsStack): add type definitions for navigation and icon props
Sacha338 Jun 19, 2024
8b054ca
refactor(FormatContribs): add TypeScript type definitions for manual …
Sacha338 Jun 19, 2024
4a57a0f
refactor(AppContext): add TypeScript type annotations and fix context…
Sacha338 Jun 19, 2024
f5b7b04
feat(useUIColors): add textLight and statusBar properties to enhance …
Sacha338 Jun 19, 2024
5937e87
refactor: remove unused imports and redundant prop in MessageScreen
Sacha338 Jun 21, 2024
d919c5b
style: remove redundant style properties in ChangelogScreen.tsx
Sacha338 Jun 21, 2024
128ef26
refactor: update EDExtendedMenu.tsx for improved module rendering and…
Sacha338 Jun 21, 2024
66af5dd
refactor: update GradesSettings.tsx for improved type safety and styl…
Sacha338 Jun 21, 2024
76e2f3d
refactor: optimize GradesSimulatorMenu.tsx for better performance and…
Sacha338 Jun 21, 2024
e96a90e
Typing and improving views
Sacha338 Jun 21, 2024
812e4a5
Tentative de résolution du conflicts
Sacha338 Jun 22, 2024
435935c
Ajout de la fonction de swipe
Sacha338 Jun 28, 2024
65a1a57
Ajout de la lib
Sacha338 Jun 28, 2024
9d74657
Petits fixs
Sacha338 Jun 28, 2024
09d1ae8
Résolution des problèmes
Sacha338 Jun 29, 2024
c2e3130
Résolution des problèmes
Sacha338 Jun 30, 2024
af807fd
Modification des styles
Sacha338 Jul 2, 2024
c919d28
Modification des plateformes des styles
Sacha338 Jul 2, 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
219 changes: 103 additions & 116 deletions components/ListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,35 @@
import React from 'react';

import {
View,
StyleSheet,
TouchableNativeFeedback,
Platform,
type ViewStyle,
} from 'react-native';

import { PressableScale } from 'react-native-pressable-scale';
import { useTheme, Text } from 'react-native-paper';
import * as Haptics from 'expo-haptics';

import { ChevronRight } from 'lucide-react-native';

interface Props {
title?: string
subtitle?: string
underTitle?: string
left?: React.ReactElement
right?: React.ReactElement
/** Most likely an icon component from `lucide-react-native`. */
icon?: React.ReactElement
style?: ViewStyle
color: string
/** Add more space between `title` and `subtitle`. */
isLarge?: boolean
onPress?: () => unknown
onLongPress?: () => unknown
fill?: boolean
/** Should take all the width from the parent. */
width?: boolean
center?: boolean
chevron?: boolean
trimSubtitle?: boolean
bottom?: React.ReactElement
title?: string;
subtitle?: string;
underTitle?: string;
left?: React.ReactNode;
right?: React.ReactNode;
icon?: React.ReactNode;
style?: any;
color: string;
isLarge?: boolean;
onPress?: () => void;
onLongPress?: () => void;
fill?: boolean;
width?: boolean;
center?: boolean;
chevron?: boolean;
trimSubtitle?: boolean;
bottom?: React.ReactNode;
}

/**
* @see https://i.imgur.com/rshTN7n.png
*/
const ListItem: React.FC<Props> = ({
title,
subtitle,
Expand Down Expand Up @@ -68,7 +58,7 @@ const ListItem: React.FC<Props> = ({
textColor = '#fff';
}

const bgMaterial = theme.colors.elevation.level1;
const bgMaterial = theme.colors.elevation?.level1;

function onPressActive() {
onPress?.();
Expand All @@ -79,28 +69,101 @@ const ListItem: React.FC<Props> = ({
if (!onPress) pressScale = 0.92;

return Platform.OS === 'ios' ? (
<PressableScale
style={{ flex: 1 }}
weight="light"
activeScale={pressScale}
<View style={[styles.listItem, style]}>
<TouchableNativeFeedback
onPress={onPressActive}
onLongPress={onLongPress}
background={TouchableNativeFeedback.Ripple(
theme.colors.surfaceDisabled,
true
)}
>
<View
style={[
{
backgroundColor: bgColor,
borderColor: theme.dark ? '#191919' : '#e5e5e5',
marginHorizontal: width ? 0 : 14,
flex: width ? 1 : undefined,
alignItems: center ? 'center' : undefined,
flexDirection: 'row',
padding: 14,
borderRadius: 12,
borderWidth: 0,
},
]}
>
{left && <View style={styles.left}>{left}</View>}
{icon && (
<View
style={[
styles.icon,
{ backgroundColor: theme.dark ? '#ffffff10' : `${color}10` },
]}
>
{icon}
</View>
)}
<View style={[styles.listItemText, { gap: isLarge ? 8 : 2 }]}>
{title && (
<Text style={[styles.listItemTextTitle, { color: textColor }]}>
{title}
</Text>
)}
{subtitle && (
<Text
style={[styles.listItemTextSubtitle, { color: textColor }]}
numberOfLines={trimSubtitle ? 1 : undefined}
ellipsizeMode="tail"
>
{subtitle}
</Text>
)}
{underTitle && (
<Text
style={[styles.listItemTextUnderTitle, { color: textColor }]}
>
{underTitle}
</Text>
)}
</View>
{right && <View style={styles.right}>{right}</View>}
{chevron && (
<View style={styles.right}>
<ChevronRight
size={24}
strokeWidth={2.5}
style={{ marginTop: -6, marginBottom: -6 }}
color={theme.dark ? '#ffffff40' : '#00000040'}
/>
</View>
)}
</View>
</TouchableNativeFeedback>
</View>
) : (
<TouchableNativeFeedback
onPress={onPressActive}
onLongPress={() => onLongPress?.()}
onLongPress={onLongPress}
background={TouchableNativeFeedback.Ripple(
theme.colors.surfaceDisabled,
true
)}
>
<View
style={[
styles.listItem,
styles.listItemContainer,
{
backgroundColor: bgColor,
backgroundColor: bgMaterial,
borderColor: theme.dark ? '#191919' : '#e5e5e5',
marginHorizontal: width ? 0 : 14,
flex: width ? 1 : void 0,
alignItems: center ? 'center' : void 0,
flex: width ? 1 : undefined,
alignItems: center ? 'center' : undefined,
},
style,
]}
>
{left && <View style={styles.left}>{left}</View>}

{icon && (
<View
style={[
Expand All @@ -111,33 +174,28 @@ const ListItem: React.FC<Props> = ({
{icon}
</View>
)}

<View style={[styles.listItemText, { gap: isLarge ? 8 : 2 }]}>
{title && (
<Text style={[styles.listItemTextTitle, { color: textColor }]}>
{title}
</Text>
)}

{subtitle && (
<Text
style={[styles.listItemTextSubtitle, { color: textColor }]}
numberOfLines={trimSubtitle ? 1 : void 0}
numberOfLines={trimSubtitle ? 1 : undefined}
ellipsizeMode="tail"
>
{subtitle}
</Text>
)}

{underTitle && (
<Text style={[styles.listItemTextUnderTitle, { color: textColor }]}>
{underTitle}
</Text>
)}
</View>

{right && <View style={styles.right}>{right}</View>}

{chevron && (
<View style={styles.right}>
<ChevronRight
Expand All @@ -149,93 +207,24 @@ const ListItem: React.FC<Props> = ({
</View>
)}
</View>
</PressableScale>
) : (
<View
style={[
styles.listItemContainer,
{ flex: 1, borderRadius: 10, overflow: 'hidden' },
{
backgroundColor: bgMaterial,
borderColor: theme.dark ? '#191919' : '#e5e5e5',
marginHorizontal: width ? 0 : 14,
flex: width ? 1 : void 0,
alignItems: center ? 'center' : void 0,
},
style,
]}
>
<TouchableNativeFeedback
style={{ flex: 1, borderRadius: 12, overflow: 'hidden' }}
onPress={onPressActive}
onLongPress={() => onLongPress?.()}
background={TouchableNativeFeedback.Ripple(
theme.colors.surfaceDisabled,
true
)}
>
<View style={styles.listItemChild}>
{left && <View style={styles.left}>{left}</View>}

{icon && (
<View
style={[
styles.icon,
{ backgroundColor: theme.dark ? '#ffffff10' : `${color}10` },
]}
>
{icon}
</View>
)}

<View style={[styles.listItemText, { gap: isLarge ? 8 : 2 }]}>
{title && (
<Text style={[styles.listItemTextTitle, { color: textColor }]}>
{title}
</Text>
)}

{subtitle && (
<Text
style={[styles.listItemTextSubtitle, { color: textColor }]}
numberOfLines={trimSubtitle ? 1 : void 0}
ellipsizeMode="tail"
>
{subtitle}
</Text>
)}

{bottom && <View>{bottom}</View>}
</View>

{right && <View style={styles.right}>{right}</View>}
</View>
</TouchableNativeFeedback>
</View>
</TouchableNativeFeedback>
);
};

const styles = StyleSheet.create({
listItem: {
flexDirection: 'row',

padding: 14,
marginHorizontal: 14,

borderRadius: 12,
borderCurve: 'continuous',
borderWidth: 0,
},
listItemContainer: {
marginHorizontal: 14,

borderRadius: 10,
borderWidth: 0,
},
listItemChild: {
padding: 14,
flexDirection: 'row',
},
listItemText: {
gap: 2,
flex: 1,
Expand Down Expand Up @@ -263,11 +252,9 @@ const styles = StyleSheet.create({
},
icon: {
marginRight: 14,

width: 38,
height: 38,
borderRadius: 30,

justifyContent: 'center',
alignItems: 'center',
},
Expand Down
29 changes: 13 additions & 16 deletions components/NativeItem.ios.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import React, { memo } from 'react';

import { View, StyleSheet, Platform, type ViewStyle } from 'react-native';

import React, { memo, ReactNode } from 'react';
import { View, StyleSheet, Platform } from 'react-native';
import { Cell } from 'react-native-tableview-simple';
import { SFSymbol } from 'react-native-sfsymbols';

import GetUIColors from '../utils/GetUIColors';

interface Props {
children: React.ReactNode
leading?: React.ReactNode
trailing?: React.ReactNode
onPress?: () => unknown
chevron?: boolean
cellProps?: Partial<React.ComponentProps<typeof Cell>>
style?: ViewStyle
innerStyle?: ViewStyle
backgroundColor?: string
children: ReactNode;
leading?: ReactNode;
trailing?: ReactNode;
onPress?: (() => false | void) | undefined;
chevron?: boolean;
cellProps?: Partial<React.ComponentProps<typeof Cell>>;
style?: View['props']['style'];
innerStyle?: View['props']['style'];
backgroundColor?: string;
}

const NativeItem = memo(({
Expand All @@ -26,7 +23,7 @@ const NativeItem = memo(({
onPress,
chevron,
backgroundColor,
}) => {
}: Props) => {
const UIColors = GetUIColors();

const cellImageView = leading && (
Expand All @@ -51,7 +48,7 @@ const NativeItem = memo(({
weight="semibold"
size={16}
color={UIColors.text + '40'}
style={{marginRight: 4}}
style={{ marginRight: 4 }}
/>
)}
</View>
Expand Down
Loading