Skip to content

Commit

Permalink
chore: migrate settings to new style and add language selection for y…
Browse files Browse the repository at this point in the history
…outube (#19)
  • Loading branch information
Duell10111 committed Mar 24, 2024
1 parent 1e86988 commit 9ef3ff6
Show file tree
Hide file tree
Showing 13 changed files with 558 additions and 41 deletions.
13 changes: 7 additions & 6 deletions src/components/GridView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, {useCallback} from "react";
import {Helpers} from "../utils/Youtube";
import {
FlatList,
FlatListProps,
Expand All @@ -8,11 +7,13 @@ import {
View,
ViewStyle,
} from "react-native";
import ShelfVideoSelectorProvider from "../context/ShelfVideoSelector";

import VideoSegment from "./VideoSegment";
import VideoMenu from "./general/VideoMenu";
import useGrid from "../hooks/home/useGrid";
import PageSectionList from "./segments/PageSectionList";
import VideoSegment from "./VideoSegment";
import ShelfVideoSelectorProvider from "../context/ShelfVideoSelector";
import useGrid from "../hooks/home/useGrid";
import {Helpers} from "../utils/Youtube";

interface Props extends Omit<FlatListProps<any>, "renderItem" | "data"> {
style?: StyleProp<ViewStyle>;
Expand All @@ -38,8 +39,8 @@ export default function GridView({
<View
style={{
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
justifyContent: "space-around",
alignItems: "flex-start",
}}>
{item.map((v, index) => (
<VideoSegment key={`${v.id}-${index}`} element={v} />
Expand Down
19 changes: 16 additions & 3 deletions src/components/segments/PageSectionList.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from "react";
import {Helpers} from "../../utils/Youtube";
import {Platform, StyleSheet, Text, View} from "react-native";
import HorizontalVideoList from "../HorizontalVideoList";

import {useAppStyle} from "../../context/AppStyleContext";
import {HorizontalData} from "../../extraction/ShelfExtraction";
import {Helpers} from "../../utils/Youtube";
import HorizontalVideoList from "../HorizontalVideoList";

interface Props {
headerText?: string;
Expand All @@ -18,7 +19,8 @@ export default function PageSectionList({headerText, content}: Props) {
}

return (
<View>
<View style={styles.containerStyle}>
<View style={styles.border} />
<Text
style={[
styles.textStyle,
Expand All @@ -28,14 +30,25 @@ export default function PageSectionList({headerText, content}: Props) {
{headerText}
</Text>
<HorizontalVideoList
containerStyle={{marginBottom: 20}}
nodes={Array.isArray(content) ? content : content.parsedData}
/>
<View style={styles.border} />
</View>
);
}

const styles = StyleSheet.create({
containerStyle: {
marginVertical: 50,
},
textStyle: {
fontSize: 25,
paddingBottom: 10,
},
border: {
width: "100%",
height: 1,
backgroundColor: "#888888",
},
});
7 changes: 3 additions & 4 deletions src/components/segments/tv/VideoCardTV.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ export default function VideoCardTV({
style,
]}>
<VideoTouchable
style={[
styles.segmentContainer,
focus ? {borderWidth: 2, borderColor: "white"} : {},
]}
style={[styles.segmentContainer, focus ? {borderColor: "white"} : {}]}
onPress={onPress}
onFocus={() => {
onElementFocused?.();
Expand Down Expand Up @@ -120,6 +117,8 @@ const styles = StyleSheet.create({
borderRadius: 25,
overflow: "hidden",
aspectRatio: 1.7,
borderWidth: 5,
borderColor: "black",
},
imageStyle: {
width: "100%",
Expand Down
203 changes: 203 additions & 0 deletions src/components/settings/SettingsItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
import {Feather} from "@expo/vector-icons";
import {StyleSheet, TouchableOpacity, View, Text} from "react-native";

interface Props {
onPress?: () => void;
icon: string;
iconBackground: string;
label: string;
value: string;
}

export default function SettingsSelectorOverview({
onPress,
icon,
iconBackground,
label,
value,
}: Props) {
return (
<View style={[styles.rowWrapper, styles.rowFirst]}>
<TouchableOpacity onPress={onPress} style={styles.row}>
<View style={[styles.rowIcon, {backgroundColor: iconBackground}]}>
<Feather
color={"#fff"}
// @ts-ignore
name={icon}
size={20}
/>
</View>

<Text style={styles.rowLabel}>{label}</Text>

<View style={styles.rowSpacer} />

<Text style={styles.rowValue}>{value}</Text>

<Feather color={"#C6C6C6"} name={"chevron-right"} size={20} />
</TouchableOpacity>
</View>
);
}

interface PropsSelectorItem {
onPress?: () => void;
label: string;
selected: boolean;
}

export function SettingsSelectorItem({
onPress,
label,
selected,
}: PropsSelectorItem) {
return (
<View style={[styles.rowWrapper, styles.rowFirst]}>
<TouchableOpacity onPress={onPress} style={styles.row}>
<Text style={styles.rowLabel}>{label}</Text>

<View style={styles.rowSpacer} />

{selected ? (
<Feather color={"#C6C6C6"} name={"check"} size={20} />
) : null}
</TouchableOpacity>
</View>
);
}

interface PropsStandaloneSelectorItem {
onPress?: () => void;
icon: string;
iconBackground: string;
label: string;
selected: boolean;
}

export function SettingsStandaloneSelector({
onPress,
icon,
iconBackground,
label,
selected,
}: PropsStandaloneSelectorItem) {
return (
<View style={[styles.rowWrapper, styles.rowFirst]}>
<TouchableOpacity onPress={onPress} style={styles.row}>
<View style={[styles.rowIcon, {backgroundColor: iconBackground}]}>
<Feather
color={"#fff"}
// @ts-ignore
name={icon}
size={20}
/>
</View>
<Text style={styles.rowLabel}>{label}</Text>

<View style={styles.rowSpacer} />

{selected ? (
<Feather color={"#C6C6C6"} name={"check"} size={20} />
) : null}
</TouchableOpacity>
</View>
);
}

interface PropsSettingsButton {
onPress?: () => void;
icon?: string;
iconBackground?: string;
label: string;
}

export function SettingsButton({
onPress,
icon,
iconBackground,
label,
}: PropsSettingsButton) {
return (
<View style={[styles.rowWrapper, styles.rowFirst]}>
<TouchableOpacity onPress={onPress} style={styles.row}>
{icon && iconBackground ? (
<View style={[styles.rowIcon, {backgroundColor: iconBackground}]}>
<Feather
color={"#fff"}
// @ts-ignore
name={icon}
size={20}
/>
</View>
) : null}

<Text style={styles.rowLabel}>{label}</Text>

<View style={styles.rowSpacer} />
</TouchableOpacity>
</View>
);
}

// <View style={styles.rowWrapper}>
// <View style={styles.row}>
// <View
// style={[styles.rowIcon, { backgroundColor: '#007AFF' }]}>
// <FeatherIcon
// color="#fff"
// name="moon"
// size={20} />
// </View>
//
// <Text style={styles.rowLabel}>Dark Mode</Text>
//
// <View style={styles.rowSpacer} />
//
// <Switch
// onValueChange={emailNotifications =>
// setForm({ ...form, emailNotifications })
// }
// value={form.emailNotifications} />
// </View>
// </View>

const styles = StyleSheet.create({
row: {
flexDirection: "row",
alignItems: "center",
justifyContent: "flex-start",
paddingRight: 24,
height: 50,
},
rowWrapper: {
borderTopWidth: 1,
borderColor: "#e3e3e3",
},
rowFirst: {
borderTopWidth: 0,
},
rowIcon: {
width: 30,
height: 30,
borderRadius: 4,
alignItems: "center",
justifyContent: "center",
marginRight: 12,
},
rowLabel: {
fontSize: 17,
fontWeight: "500",
color: "#000",
},
rowSpacer: {
flexGrow: 1,
flexShrink: 1,
flexBasis: 0,
},
rowValue: {
fontSize: 17,
fontWeight: "500",
color: "#8B8B8B",
marginRight: 4,
},
});
43 changes: 43 additions & 0 deletions src/components/settings/SettingsSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from "react";
import {StyleProp, StyleSheet, Text, View, ViewStyle} from "react-native";

interface Props {
children?: React.ReactNode;
sectionTitle?: string;
style?: StyleProp<ViewStyle>;
}

export default function SettingsSection({
children,
style,
sectionTitle,
}: Props) {
return (
<View style={[styles.section, style]}>
<Text style={styles.sectionTitle}>{sectionTitle}</Text>
<View style={styles.sectionBody}>{children}</View>
</View>
);
}

const styles = StyleSheet.create({
section: {
paddingTop: 12,
},
sectionTitle: {
marginVertical: 8,
marginHorizontal: 24,
fontSize: 14,
fontWeight: "600",
color: "#a7a7a7",
textTransform: "uppercase",
letterSpacing: 1.2,
},
sectionBody: {
paddingLeft: 24,
backgroundColor: "#fff",
borderTopWidth: 1,
borderBottomWidth: 1,
borderColor: "#e3e3e3",
},
});
Loading

0 comments on commit 9ef3ff6

Please sign in to comment.