Skip to content

Commit

Permalink
Merge pull request #97 from flexn-io/chore/dependency-require-cycles
Browse files Browse the repository at this point in the history
Chore: Add types, fix linting issues, dead code and other improvements
  • Loading branch information
aurimasmi committed Jun 12, 2023
2 parents 3e01126 + d6608f3 commit bd892a6
Show file tree
Hide file tree
Showing 69 changed files with 1,161 additions and 1,308 deletions.
2 changes: 0 additions & 2 deletions packages/app-harness/src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,12 @@ const Button = ({
accessible,
accessibilityLabel,
onPress,
activeOpacity,
focusContext,
focusOptions,
}: ButtonProps) => (
<Pressable
style={[styles.button, style]}
onPress={onPress}
activeOpacity={activeOpacity ?? 0.2}
testID={testID}
accessible={accessible}
accessibilityLabel={accessibilityLabel}
Expand Down
22 changes: 9 additions & 13 deletions packages/app-harness/src/screens/directionalFocus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ import Screen from './screen';
import { Button } from '../components/Button';
import { Ratio } from '../utils';

const border = {
type: 'border',
focus: {
borderWidth: 5,
borderColor: 'yellow',
},
blur: {
borderWidth: 4,
borderColor: '#FFFFFF',
},
};

const { height } = Dimensions.get('screen');

const kittyNames = ['Abby', 'Angel', 'Annie', 'Baby', 'Bailey', 'Bandit'];
Expand Down Expand Up @@ -47,7 +35,15 @@ const DirectionalFocus = () => {
<Pressable
style={styles.packshot}
focusRepeatContext={focusRepeatContext}
focusOptions={{ animatorOptions: border }}
focusOptions={{
animator: {
type: 'border',
focus: {
borderWidth: 5,
borderColor: 'yellow',
},
},
}}
>
<Image source={{ uri: item.backgroundImage }} style={styles.image} />
</Pressable>
Expand Down
28 changes: 8 additions & 20 deletions packages/app-harness/src/screens/grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,6 @@ import { View, FlashList, Pressable, Image, CreateListRenderItemInfo } from '@fl
import Screen from './screen';
import { Ratio } from '../utils';

// const border = {
// type: 'border',
// focus: {
// borderWidth: 5,
// borderColor: 'yellow',
// },
// blur: {
// borderWidth: 4,
// borderColor: '#FFFFFF',
// },
// };

const scale = {
type: 'scale',
focus: {
scale: 1.4,
},
};

const kittyNames = ['Abby', 'Angel', 'Annie', 'Baby', 'Bailey', 'Bandit'];

function interval(min = 0, max = kittyNames.length - 1) {
Expand Down Expand Up @@ -50,7 +31,14 @@ const Grid = () => {
<Pressable
style={styles.packshot}
focusRepeatContext={focusRepeatContext}
focusOptions={{ animatorOptions: scale }}
focusOptions={{
animator: {
type: 'scale',
focus: {
scale: 1.4,
},
},
}}
>
<Image source={{ uri: item.backgroundImage }} style={styles.image} />
</Pressable>
Expand Down
22 changes: 9 additions & 13 deletions packages/app-harness/src/screens/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ import { View, FlashList, Pressable, Image, ScrollView, CreateListRenderItemInfo
import Screen from './screen';
import { Ratio } from '../utils';

const border = {
type: 'border',
focus: {
borderWidth: Ratio(8),
borderColor: 'blue',
},
blur: {
borderWidth: Ratio(4),
borderColor: '#FFFFFF',
},
};

const kittyNames = ['Abby', 'Angel', 'Annie', 'Baby', 'Bailey', 'Bandit'];

function interval(min = 0, max = kittyNames.length - 1) {
Expand Down Expand Up @@ -43,7 +31,15 @@ const Row = () => {
<Pressable
style={styles.packshot}
focusRepeatContext={focusRepeatContext}
focusOptions={{ animatorOptions: border }}
focusOptions={{
animator: {
type: 'border',
focus: {
borderWidth: Ratio(8),
borderColor: 'blue',
},
},
}}
>
<Image source={{ uri: item.backgroundImage }} style={styles.image} />
</Pressable>
Expand Down
15 changes: 3 additions & 12 deletions packages/app-harness/src/screens/overflow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ const Overflow = () => {
<View style={{ backgroundColor: '#222222', flex: 1 }}>
<Screen
style={{ backgroundColor: '#222222', position: 'absolute' }}
group="layer1"
focusOptions={{ nextFocusRight: ['layer2'], focusKey: 'layer1' }}
stealFocus={false}
focusOptions={{ nextFocusRight: ['layer2'], focusKey: 'layer1', group: 'layer1', stealFocus: false }}
>
<View style={{ position: 'absolute' }}>
{layer1Buttons.map((_, i) => (
Expand All @@ -32,9 +30,7 @@ const Overflow = () => {
</Screen>
<Screen
style={{ backgroundColor: '#222222', position: 'absolute' }}
group="layer2"
focusOptions={{ nextFocusLeft: ['layer1'], focusKey: 'layer2' }}
stealFocus={false}
focusOptions={{ nextFocusLeft: ['layer1'], focusKey: 'layer2', group: 'layer2', stealFocus: false }}
>
<View style={{ position: 'absolute' }}>
{layer2Buttons.map((_, i) => (
Expand All @@ -47,12 +43,7 @@ const Overflow = () => {
))}
</View>
</Screen>
<Screen
style={{ backgroundColor: '#222222', position: 'absolute' }}
stealFocus
// group="layer2"
// focusOptions={{ nextFocusLeft: ['layer1'], focusKey: 'layer2' }}
>
<Screen style={{ backgroundColor: '#222222', position: 'absolute' }} focusOptions={{ stealFocus: false }}>
<View style={{ position: 'absolute' }}>
{layer3Buttons.map((_, i) => (
<Button
Expand Down
54 changes: 31 additions & 23 deletions packages/app-harness/src/screens/pressableAnimations.tsx
Original file line number Diff line number Diff line change
@@ -1,68 +1,76 @@
import React from 'react';
import { StyleSheet } from 'react-native';
import { Text, View, Pressable } from '@flexn/create';
import {
Text,
View,
Pressable,
AnimatorBackground,
AnimatorBorder,
AnimatorScale,
AnimatorScaleWithBorder,
} from '@flexn/create';
import Screen from './screen';
import { Ratio } from '../utils';

const scale = {
const scale: AnimatorScale = {
type: 'scale',
focus: {
scale: 1.2,
},
blur: {
scale: 1,
},
// blur: {
// scale: 1,
// },
// duration: 150,
};

const border = {
const border: AnimatorBorder = {
type: 'border',
focus: {
borderWidth: 5,
borderColor: 'yellow',
},
blur: {
borderWidth: 1,
borderColor: '#FFFFFF',
},
// blur: {
// borderWidth: 1,
// borderColor: '#FFFFFF',
// },
};

const bgColor = {
const bgColor: AnimatorBackground = {
type: 'background',
focus: {
backgroundColor: '#FF0000',
},
blur: {
backgroundColor: '#FFFFFF',
},
// blur: {
// backgroundColor: '#FFFFFF',
// },
};
const scaleBorder = {
const scaleBorder: AnimatorScaleWithBorder = {
type: 'scale_with_border',
focus: {
scale: 1.5,
borderWidth: 3,
borderColor: 'yellow',
},
blur: {
borderWidth: 1,
borderColor: '#FFFFFF',
},
// blur: {
// borderWidth: 1,
// borderColor: '#FFFFFF',
// },
};

const PressableAnimations = () => {
return (
<Screen style={{ backgroundColor: '#222222' }}>
<View style={{ left: 50, top: 50 }}>
<Pressable style={styles.animation1} focusOptions={{ animatorOptions: scale }}>
<Pressable style={styles.animation1} focusOptions={{ animator: scale }}>
<Text>Animation scale</Text>
</Pressable>
<Pressable style={styles.animation2} focusOptions={{ animatorOptions: bgColor }}>
<Pressable style={styles.animation2} focusOptions={{ animator: bgColor }}>
<Text>Animation bg color</Text>
</Pressable>
<Pressable style={styles.animation2} focusOptions={{ animatorOptions: scaleBorder }}>
<Pressable style={styles.animation2} focusOptions={{ animator: scaleBorder }}>
<Text>Animation scale border</Text>
</Pressable>
<Pressable style={styles.animation2} focusOptions={{ animatorOptions: border }}>
<Pressable style={styles.animation2} focusOptions={{ animator: border }}>
<Text>Animation border</Text>
</Pressable>
</View>
Expand Down
28 changes: 8 additions & 20 deletions packages/app-harness/src/screens/row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,6 @@ import { View, FlashList, Pressable, Image, CreateListRenderItemInfo } from '@fl
import Screen from './screen';
import { Ratio } from '../utils';

// const border = {
// type: 'border',
// focus: {
// borderWidth: 5,
// borderColor: 'yellow',
// },
// blur: {
// borderWidth: 4,
// borderColor: '#FFFFFF',
// },
// };

const scale = {
type: 'scale',
focus: {
scale: 1.4,
},
};

const kittyNames = ['Abby', 'Angel', 'Annie', 'Baby', 'Bailey', 'Bandit'];

function interval(min = 0, max = kittyNames.length - 1) {
Expand Down Expand Up @@ -50,7 +31,14 @@ const Row = () => {
<Pressable
style={styles.packshot}
focusRepeatContext={focusRepeatContext}
focusOptions={{ animatorOptions: scale }}
focusOptions={{
animator: {
type: 'scale',
focus: {
scale: 1.4,
},
},
}}
>
<Image source={{ uri: item.backgroundImage }} style={styles.image} />
</Pressable>
Expand Down
10 changes: 2 additions & 8 deletions packages/app-harness/src/screens/screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Screen as FMScreen, ScreenProps, ScreenStates } from '@flexn/create';
import { useFocusEffect } from '@react-navigation/native';
import React, { useState } from 'react';

const Screen = ({ children, stealFocus, focusOptions, style, ...props }: ScreenProps) => {
const Screen = ({ children, focusOptions, style, ...props }: ScreenProps) => {
const [screenState, setScreenState] = useState<ScreenStates>('foreground');

useFocusEffect(
Expand All @@ -16,13 +16,7 @@ const Screen = ({ children, stealFocus, focusOptions, style, ...props }: ScreenP
);

return (
<FMScreen
screenState={screenState}
stealFocus={stealFocus}
focusOptions={focusOptions}
style={style}
{...props}
>
<FMScreen focusOptions={{ ...focusOptions, screenState }} style={style} {...props}>
{children}
</FMScreen>
);
Expand Down
16 changes: 11 additions & 5 deletions packages/app-harness/src/screens/scrollToTop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ const border = {
borderWidth: 5,
borderColor: 'yellow',
},
blur: {
borderWidth: 4,
borderColor: 'grey',
},
};

const kittyNames = ['Abby', 'Angel', 'Annie', 'Baby', 'Bailey', 'Bandit'];
Expand Down Expand Up @@ -46,7 +42,15 @@ const ScrollToTop = () => {
<Pressable
style={styles.packshot}
focusRepeatContext={focusRepeatContext}
focusOptions={{ animatorOptions: border }}
focusOptions={{
animator: {
type: 'border',
focus: {
borderColor: '#FF0000',
borderWidth: 2,
},
},
}}
>
<Image source={{ uri: item.backgroundImage }} style={styles.image} />
</Pressable>
Expand Down Expand Up @@ -142,6 +146,8 @@ const styles = StyleSheet.create({
// borderColor: 'red',
// borderWidth: 1,
margin: 5,
borderWidth: 4,
borderColor: 'grey',
// borderWidth: 2,
},
image: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public AbstractAnimator(ReactViewGroup view, ReadableMap args) {
this.mView = view;
this.mArgs = args;
this.AnimatorProperty2 = new AnimatorProperty(args);
// Log.d("HOW_MANY", "TIMESS_HERE");
}

public abstract void onFocus(boolean animated);
Expand Down
4 changes: 2 additions & 2 deletions packages/create/src/components/App/index.native.tv.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useEffect, useRef } from 'react';
import { View as RNView, ScrollView as RNScrollView, TouchableOpacity, findNodeHandle } from 'react-native';
import { View as RNView, ScrollView as RNScrollView, TouchableOpacity, findNodeHandle, ViewProps } from 'react-native';
import { isPlatformAndroidtv, isPlatformFiretv } from '@rnv/renative';
import KeyHandler from '../../focusManager/service/keyHandler';

const isAndroidBased = isPlatformAndroidtv || isPlatformFiretv;

export default function App({ children, ...props }: { children: any }) {
export default function App({ children, ...props }: ViewProps) {
const focusTrapRef = useRef<TouchableOpacity>(null);
useEffect(() => {
const Handler = new KeyHandler();
Expand Down
6 changes: 3 additions & 3 deletions packages/create/src/components/App/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { StyleProp, View, ViewStyle } from 'react-native';
import { View, ViewProps } from 'react-native';

export default function App({ children, style }: { children: React.ReactNode; style?: StyleProp<ViewStyle> }) {
return <View style={style}>{children}</View>;
export default function App(props: ViewProps) {
return <View {...props} />;
}
Loading

0 comments on commit bd892a6

Please sign in to comment.