|
|
@@ -16,6 +16,7 @@ export default function DayLight() {
|
|
|
const [authInfo, setAuthInfo] = useState(null)
|
|
|
const [sunriseTime, setSunriseTime] = useState('06:00')
|
|
|
const [sunsetTime, setSunsetTime] = useState('18:00')
|
|
|
+ const [showLocatin, setShowLocation] = useState(true)
|
|
|
const dayNight = useSelector((state: any) => state.dayNight);
|
|
|
const user = useSelector((state: any) => state.user);
|
|
|
const dispatch = useDispatch();
|
|
|
@@ -27,13 +28,13 @@ export default function DayLight() {
|
|
|
if (authInfo)
|
|
|
dispatch(updateMember({ isMember: user.test_user, gpsInfo: authInfo }))
|
|
|
if (user.test_user && authInfo) {
|
|
|
- if ((authInfo as any).daylights.length==1){
|
|
|
+ if ((authInfo as any).daylights.length == 1) {
|
|
|
setSunriseTime((authInfo as any).daylights[0].sunrise)
|
|
|
}
|
|
|
else {
|
|
|
setSunriseTime((authInfo as any).daylights[1].sunrise)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
setSunsetTime((authInfo as any).daylights[0].sunset)
|
|
|
}
|
|
|
else {
|
|
|
@@ -48,8 +49,8 @@ export default function DayLight() {
|
|
|
(data as any).latitude = (data as any).lat;
|
|
|
(data as any).longitude = (data as any).lng;
|
|
|
setAuthInfo(data as any)
|
|
|
-
|
|
|
- if ((data as any).daylights.length==1){
|
|
|
+
|
|
|
+ if ((data as any).daylights.length == 1) {
|
|
|
setSunriseTime((data as any).daylights[0].sunrise)
|
|
|
}
|
|
|
else {
|
|
|
@@ -84,6 +85,9 @@ export default function DayLight() {
|
|
|
const isShow = await getStorage('showLightRing') || false
|
|
|
setShowRing(isShow)
|
|
|
|
|
|
+ const hideLocation = await getStorage('hideLocation') || false
|
|
|
+ setShowLocation(!hideLocation)
|
|
|
+
|
|
|
global.showNightRing = isShow
|
|
|
global.refreshIndex()
|
|
|
|
|
|
@@ -212,20 +216,28 @@ export default function DayLight() {
|
|
|
<Text>Sunrise tomororow</Text>
|
|
|
<Text>{sunriseTime}</Text>
|
|
|
</View>
|
|
|
- <Text className='daylight_note'>{isMember && authInfo ? 'Calculated based on your location.' : 'Sunset and sunrise times are global average. For actual times at your location, join our Pro program.'}</Text>
|
|
|
+ <Text className='daylight_note'>{
|
|
|
+ !isMember ? 'Sunset and sunrise times are global average. For actual times at your location, join our Pro program.' :
|
|
|
+ authInfo ? 'Calculated based on your location.' :
|
|
|
+ 'Sunset and sunrise times are global average. For actual times at your location, enter your location.'
|
|
|
+ }</Text>
|
|
|
+ {/* <Text className='daylight_note'>{isMember && authInfo ? 'Calculated based on your location.' : 'Sunset and sunrise times are global average. For actual times at your location, join our Pro program.'}</Text> */}
|
|
|
{
|
|
|
isMember ? <View>
|
|
|
- <View className='daylight_item' onClick={auth}>
|
|
|
- <Text style={{ flex: 1 }}>Location</Text>
|
|
|
- {
|
|
|
- authInfo ? <Text className='address'>{(authInfo as any).address.city}</Text> :
|
|
|
- <Text>Enter</Text>
|
|
|
- }
|
|
|
- <Image className="daylight_arrow" src={require('@/assets/images/arrow3.png')} />
|
|
|
- </View>
|
|
|
+ {
|
|
|
+ showLocatin && <View className='daylight_item' onClick={auth}>
|
|
|
+ <Text style={{ flex: 1 }}>Location</Text>
|
|
|
+ {
|
|
|
+ authInfo ? <Text className='address'>{(authInfo as any).address.city}</Text> :
|
|
|
+ <Text>Enter</Text>
|
|
|
+ }
|
|
|
+ <Image className="daylight_arrow" src={require('@/assets/images/arrow3.png')} />
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
{
|
|
|
- authInfo && <View className='daylight_item' >
|
|
|
+ authInfo && showLocatin && <View className='daylight_item' >
|
|
|
<Text style={{ flex: 1 }}>Latitude</Text>
|
|
|
|
|
|
<Text>{(authInfo as any).latitude}</Text>
|
|
|
@@ -234,7 +246,7 @@ export default function DayLight() {
|
|
|
</View>
|
|
|
}
|
|
|
{
|
|
|
- authInfo && <View className='daylight_item'>
|
|
|
+ authInfo && showLocatin && <View className='daylight_item'>
|
|
|
<Text style={{ flex: 1 }}>Longitude</Text>
|
|
|
|
|
|
<Text>{(authInfo as any).longitude}</Text>
|
|
|
@@ -242,7 +254,7 @@ export default function DayLight() {
|
|
|
</View>
|
|
|
}
|
|
|
{
|
|
|
- authInfo && <View className='daylight_item'>
|
|
|
+ authInfo && showLocatin && <View className='daylight_item'>
|
|
|
<Text style={{ flex: 1 }}>Time zone</Text>
|
|
|
|
|
|
<Text>{timezone}</Text>
|
|
|
@@ -250,7 +262,17 @@ export default function DayLight() {
|
|
|
</View>
|
|
|
}
|
|
|
{
|
|
|
- authInfo && <Text style={{ color: '#fff' }} onClick={clearData}>清除位置数据</Text>
|
|
|
+ authInfo && <Text style={{ color: '#fff' }} onClick={() => {
|
|
|
+ var enable = !showLocatin
|
|
|
+ setShowLocation(enable)
|
|
|
+ Taro.setStorage({
|
|
|
+ key: 'hideLocation',
|
|
|
+ data: !enable
|
|
|
+ })
|
|
|
+ }}>{showLocatin ? 'Hide my location' : 'Show my location'}</Text>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ authInfo && showLocatin && <Text style={{ color: '#fff' }} onClick={clearData}>清除位置数据</Text>
|
|
|
}
|
|
|
|
|
|
</View> :
|