Skip to content

Commit 1e802d7

Browse files
authored
Merge pull request #60 from monkvision/feature/SightsWheel/wip
SightsWheel component
2 parents 42e4ca9 + 2dc4d85 commit 1e802d7

File tree

16 files changed

+292
-49
lines changed

16 files changed

+292
-49
lines changed

.github/workflows/corejs-analyze.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: @monkvision/corejs
1+
name: corejs
22

33
on:
44
push:

.github/workflows/react-native-analyze.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: @monkvision/react-native
1+
name: react-native
22

33
on:
44
push:

packages/react-native-views/src/components/CameraView/index.jsx

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,11 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';
22
import PropTypes from 'prop-types';
33
import noop from 'lodash.noop';
44

5+
import { Camera, CameraSideBar, Mask, PicturesScrollPreview, utils } from '@monkvision/react-native/src/index';
56
import { View, Platform, SafeAreaView, StatusBar, StyleSheet } from 'react-native';
67
import { FAB } from 'react-native-paper';
78

8-
import {
9-
Camera,
10-
CameraSideBar,
11-
PicturesScrollPreview,
12-
Mask,
13-
utils,
14-
} from '@monkvision/react-native';
15-
169
import ActivityIndicatorView from '../ActivityIndicatorView';
17-
1810
import useSights from './useSights';
1911

2012
const styles = StyleSheet.create({
@@ -74,7 +66,7 @@ export default function CameraView({
7466
const [fakeActivity, setFakeActivity] = useState(null);
7567
const [camera, setCamera] = useState();
7668
const [pictures, setPictures] = useState({});
77-
const { activeSight, activeSightIndex, nextSightProps } = useSights(sights);
69+
const { activeSight, nextSightProps } = useSights(sights);
7870

7971
// PICTURES
8072
const handleTakePicture = useCallback(async () => {
@@ -102,6 +94,7 @@ export default function CameraView({
10294
const handleCloseCamera = useCallback(() => {
10395
onCloseCamera(pictures);
10496
}, [onCloseCamera, pictures]);
97+
10598
const handleCameraReady = useCallback(setCamera, [setCamera]);
10699

107100
// UI
@@ -113,7 +106,7 @@ export default function CameraView({
113106
useEffect(() => {
114107
const fakeActivityId = setTimeout(() => {
115108
setFakeActivity(null);
116-
}, 750);
109+
}, 500);
117110

118111
setFakeActivity(fakeActivityId);
119112

@@ -125,8 +118,7 @@ export default function CameraView({
125118
<StatusBar hidden />
126119
<SafeAreaView style={styles.container}>
127120
<PicturesScrollPreview
128-
activeSightLabel={activeSight.label}
129-
activeSightIndex={activeSightIndex}
121+
activeSight={activeSight}
130122
sights={sights}
131123
pictures={pictures}
132124
ref={scrollRef}
@@ -183,16 +175,16 @@ CameraView.defaultProps = {
183175
onTakePicture: noop,
184176
sights: [
185177
['abstractFront', [null, 0, null], 'front'],
186-
['abstractFrontLeft', [null, 30, null], 'front left'],
187-
['abstractFrontLateralLeft', [null, 60, null], 'front side left'],
188-
['abstractMiddleLateralLeft', [null, 90, null], 'middle side left'],
189-
['abstractRearLateralLeft', [null, 120, null], 'read side left'],
190-
['abstractRearLeft', [null, 150, null], 'rear left'],
191-
['abstractRear', [null, 180, null], 'rear'],
192-
['abstractRearRight', [null, 210, null], 'rear right'],
178+
['abstractFrontRight', [null, 330, null], 'front right'],
179+
['abstractFrontLateralRight', [null, 300, null], 'front side right'],
193180
['abstractRearLateralRight', [null, 240, null], 'rear side right'],
194181
['abstractMiddleLateralRight', [null, 270, null], 'middle side right'],
195-
['abstractFrontLateralRight', [null, 300, null], 'front side right'],
196-
['abstractFrontRight', [null, 330, null], 'front right'],
182+
['abstractRearRight', [null, 210, null], 'rear right'],
183+
['abstractFrontLeft', [null, 30, null], 'front left'],
184+
['abstractRear', [null, 180, null], 'rear'],
185+
['abstractRearLeft', [null, 150, null], 'rear left'],
186+
['abstractRearLateralLeft', [null, 120, null], 'read side left'],
187+
['abstractMiddleLateralLeft', [null, 90, null], 'middle side left'],
188+
['abstractFrontLateralLeft', [null, 60, null], 'front side left'],
197189
],
198190
};

packages/react-native/src/assets/sightMasks.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ export { default as abstractRearLateralLeft } from './sightMasks/abstract-rear-l
1010
export { default as abstractRearLateralRight } from './sightMasks/abstract-rear-lateral-right.png';
1111
export { default as abstractRearLeft } from './sightMasks/abstract-rear-left.png';
1212
export { default as abstractRearRight } from './sightMasks/abstract-rear-right.png';
13+
export { default as vin } from './sightMasks/vin.png';

packages/react-native/src/assets/sightMasks.native.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ export const abstractRearLateralLeft = require('./sightMasks/abstract-rear-later
1111
export const abstractRearLateralRight = require('./sightMasks/abstract-rear-lateral-right.png');
1212
export const abstractRearLeft = require('./sightMasks/abstract-rear-left.png');
1313
export const abstractRearRight = require('./sightMasks/abstract-rear-right.png');
14+
export const vin = require('./sightMasks/vin.png');
641 Bytes
Loading
Lines changed: 4 additions & 0 deletions
Loading
7.39 KB
Loading
Lines changed: 5 additions & 0 deletions
Loading

packages/react-native/src/components/PicturesScrollPreview/index.jsx

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,39 @@ import PropTypes from 'prop-types';
33
import isEmpty from 'lodash.isempty';
44
import isPlainObject from 'lodash.isplainobject';
55

6-
import { Image, Platform, SafeAreaView, ScrollView, StyleSheet } from 'react-native';
7-
import { Surface, Chip, useTheme } from 'react-native-paper';
6+
import { Image, Platform, SafeAreaView, ScrollView, StyleSheet, View } from 'react-native';
7+
import { Surface, Chip, useTheme, Badge } from 'react-native-paper';
8+
import { Sight } from '@monkvision/corejs';
89

10+
import SightsWheel from '../SightsWheel';
911
import * as sightMasks from '../../assets/sightMasks';
1012

1113
const styles = StyleSheet.create({
1214
root: {
1315
display: 'flex',
14-
width: 125,
16+
width: 116,
1517
...Platform.select({
1618
native: { height: '100%' },
1719
default: { height: '100vh' },
1820
}),
1921
},
20-
chip: {
22+
topView: {
23+
display: 'flex',
24+
alignItems: 'center',
25+
width: 125,
2126
position: 'absolute',
22-
alignSelf: 'center',
2327
marginVertical: 8,
2428
marginHorizontal: 4,
2529
},
30+
chip: {
31+
alignSelf: 'center',
32+
},
2633
chipText: {
2734
fontSize: 12,
2835
fontWeight: '400',
2936
},
3037
scrollContainer: {
31-
paddingTop: 48,
38+
paddingTop: 166,
3239
paddingBottom: 16,
3340
},
3441
surface: {
@@ -53,21 +60,32 @@ const styles = StyleSheet.create({
5360
marginHorizontal: 12.5,
5461
marginVertical: 4,
5562
},
63+
badge: {
64+
position: 'absolute',
65+
top: 8,
66+
right: 8,
67+
},
5668
});
5769

58-
const PicturesScrollPreview = forwardRef(({ activeSightLabel, pictures, sights }, ref) => {
70+
const PicturesScrollPreview = forwardRef(({
71+
activeSight,
72+
pictures,
73+
showPicture,
74+
sights,
75+
}, ref) => {
5976
const { colors } = useTheme();
6077

6178
return (
6279
<SafeAreaView style={styles.root} ref={ref}>
6380
<ScrollView style={styles.scrollContainer}>
6481
{sights.map(([id]) => {
6582
const picture = pictures[id];
66-
const source = isPlainObject(picture)
83+
const isImage = isPlainObject(picture) && showPicture === true;
84+
const source = isImage
6785
? picture.source
6886
: sightMasks[id];
6987

70-
if (isPlainObject(picture)) {
88+
if (isImage) {
7189
return (
7290
<Image
7391
key={`picture-${id}`}
@@ -79,6 +97,12 @@ const PicturesScrollPreview = forwardRef(({ activeSightLabel, pictures, sights }
7997

8098
return (
8199
<Surface key={id} style={[styles.surface, { backgroundColor: colors.primary }]}>
100+
<Badge
101+
visible={isPlainObject(picture)}
102+
style={[styles.badge, { backgroundColor: colors.success }]}
103+
>
104+
✔️
105+
</Badge>
82106
<Image
83107
key={`picture-${id}`}
84108
source={source}
@@ -88,26 +112,38 @@ const PicturesScrollPreview = forwardRef(({ activeSightLabel, pictures, sights }
88112
);
89113
})}
90114
</ScrollView>
91-
{!isEmpty(activeSightLabel) && (
92-
<Chip
93-
style={[styles.chip, { backgroundColor: colors.accent }]}
94-
textStyle={styles.chipText}
95-
>
96-
{activeSightLabel}
97-
</Chip>
115+
{(activeSight !== null && !isEmpty(activeSight.label)) && (
116+
<View style={styles.topView}>
117+
<SightsWheel
118+
sights={sights.map((s) => new Sight(...s))}
119+
filledSightIds={Object.keys(pictures)}
120+
activeSightId={activeSight.id}
121+
/>
122+
<Chip
123+
style={[styles.chip, { backgroundColor: colors.accent }]}
124+
textStyle={styles.chipText}
125+
>
126+
{activeSight.label}
127+
</Chip>
128+
</View>
98129
)}
99130
</SafeAreaView>
100131
);
101132
});
102133

103134
PicturesScrollPreview.propTypes = {
104-
activeSightLabel: PropTypes.string,
135+
activeSight: PropTypes.shape({
136+
id: PropTypes.string,
137+
label: PropTypes.string,
138+
}),
105139
pictures: PropTypes.objectOf(PropTypes.object).isRequired,
140+
showPicture: PropTypes.bool,
106141
sights: PropTypes.arrayOf(PropTypes.array).isRequired,
107142
};
108143

109144
PicturesScrollPreview.defaultProps = {
110-
activeSightLabel: '',
145+
activeSight: null,
146+
showPicture: false,
111147
};
112148

113149
export default PicturesScrollPreview;

0 commit comments

Comments
 (0)