Skip to content

Commit baa33ad

Browse files
committed
fix(template): transparency fixed on Android & removed custom lint rules
Better exports properties and paths. release-npm
1 parent 1fb87f9 commit baa33ad

File tree

3 files changed

+38
-29
lines changed

3 files changed

+38
-29
lines changed

template/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ To test your plugin on a device run the following to create a React Native app u
3838
```
3939
npm run app
4040
cd app
41-
react-native run-ios / react-native run-android
41+
npm run ios / npm run android
4242
```
4343

4444
The following command will automatically copy over changes made to the plugin to the app.

template/index.tsx

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react'
2-
import { StyleSheet, View, Text, TouchableOpacity } from 'react-native'
2+
import { StyleSheet, View, Text, Pressable } from 'react-native'
33

44
const rotation = (percent: number, base: number) => ({
55
transform: [{ rotateZ: `${base + (percent > 50 ? 50 : percent) * 3.6}deg` }],
@@ -20,14 +20,18 @@ const styles = StyleSheet.create({
2020
justifyContent: 'center',
2121
alignItems: 'center',
2222
},
23+
highlight: {
24+
borderColor: '#474747',
25+
},
2326
firstProgressLayer: {
2427
width: 200,
2528
height: 200,
2629
borderWidth: 20,
2730
borderRadius: 100,
2831
position: 'absolute',
29-
borderLeftColor: 'transparent',
30-
borderBottomColor: 'transparent',
32+
// Transparent borders not working on Android, use an almost transparent color.
33+
borderLeftColor: 'rgba(0, 0, 0, 0.01)',
34+
borderBottomColor: 'rgba(0, 0, 0, 0.01)',
3135
borderRightColor: 'gray',
3236
borderTopColor: 'gray',
3337
transform: [{ rotateZ: '-135deg' }],
@@ -38,8 +42,8 @@ const styles = StyleSheet.create({
3842
position: 'absolute',
3943
borderWidth: 20,
4044
borderRadius: 100,
41-
borderLeftColor: 'transparent',
42-
borderBottomColor: 'transparent',
45+
borderLeftColor: 'rgba(0, 0, 0, 0.01)',
46+
borderBottomColor: 'rgba(0, 0, 0, 0.01)',
4347
borderRightColor: 'gray',
4448
borderTopColor: 'gray',
4549
transform: [{ rotateZ: '45deg' }],
@@ -50,12 +54,16 @@ const styles = StyleSheet.create({
5054
position: 'absolute',
5155
borderWidth: 20,
5256
borderRadius: 100,
53-
borderLeftColor: 'transparent',
54-
borderBottomColor: 'transparent',
57+
borderLeftColor: 'rgba(0, 0, 0, 0.01)',
58+
borderBottomColor: 'rgba(0, 0, 0, 0.01)',
5559
borderRightColor: 'black',
5660
borderTopColor: 'black',
5761
transform: [{ rotateZ: '-135deg' }],
5862
},
63+
highlightOffset: {
64+
borderRightColor: '#474747',
65+
borderTopColor: '#474747',
66+
},
5967
textOverlay: {
6068
position: 'absolute',
6169
alignItems: 'center',
@@ -64,9 +72,12 @@ const styles = StyleSheet.create({
6472
text: {
6573
fontSize: 40,
6674
},
75+
textBold: {
76+
fontWeight: 'bold',
77+
},
6778
})
6879

69-
const ThirdLayer = ({ percent }: { percent: number }) => {
80+
const ThirdLayer = ({ percent, pressed }: { percent: number; pressed: boolean }) => {
7081
if (percent > 50) {
7182
return (
7283
<View
@@ -76,7 +87,7 @@ const ThirdLayer = ({ percent }: { percent: number }) => {
7687
)
7788
}
7889

79-
return <View style={styles.offsetLayer} />
90+
return <View style={[styles.offsetLayer, pressed && styles.highlightOffset]} />
8091
}
8192

8293
export type Props = {
@@ -89,15 +100,17 @@ export const <%= pascal %> = ({ initialCount = 0 }: Props) => {
89100

90101
return (
91102
<View style={styles.view}>
92-
<TouchableOpacity onPress={() => setCount(count + 1)}>
93-
<View style={styles.container}>
94-
<View key={percent} style={[styles.firstProgressLayer, rotation(percent, -135)]} />
95-
<ThirdLayer percent={percent} />
96-
<View pointerEvents="none" style={styles.textOverlay}>
97-
<Text style={styles.text}>{count}</Text>
103+
<Pressable onPress={() => setCount(count + 1)}>
104+
{({ pressed }) => (
105+
<View style={[styles.container, pressed && styles.highlight]}>
106+
<View key={percent} style={[styles.firstProgressLayer, rotation(percent, -135)]} />
107+
<ThirdLayer percent={percent} pressed={pressed} />
108+
<View pointerEvents="none" style={styles.textOverlay}>
109+
<Text style={[styles.text, pressed && styles.textBold]}>{count}</Text>
110+
</View>
98111
</View>
99-
</View>
100-
</TouchableOpacity>
112+
)}
113+
</Pressable>
101114
</View>
102115
)
103116
}

template/package.json

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
"name": "<%= name %>",
33
"version": "1.0.0",
44
"license": "MIT",
5-
"main": "dist/index.js",
5+
"main": "./dist/index.js",
66
"type": "module",
7-
"types": "dist/index.d.ts",
7+
"types": "./dist/index.d.ts",
88
"exports": {
9-
".": "./dist/index.js",
9+
".": {
10+
"types": "./dist/index.d.ts",
11+
"default": "./dist/index.js"
12+
},
1013
"./package.json": "./package.json"
1114
},
1215
"scripts": {
@@ -69,14 +72,7 @@
6972
"files": [
7073
"*.ts",
7174
"*.tsx"
72-
],
73-
"rules": {
74-
"@typescript-eslint/no-shadow": [
75-
"error"
76-
],
77-
"no-shadow": "off",
78-
"no-undef": "off"
79-
}
75+
]
8076
}
8177
]
8278
},

0 commit comments

Comments
 (0)