Leon 1 năm trước cách đây
mục cha
commit
f8374a5c25

+ 1 - 1
ios/AppDelegate.mm

@@ -130,7 +130,7 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
 - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
 {
 //  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
-#if DEBUGaa
+#if DEBUG
   return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
 #else
   return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

+ 2 - 2
ios/hola.xcodeproj/project.pbxproj

@@ -576,7 +576,7 @@
 				CODE_SIGN_ENTITLEMENTS = hola/hola.entitlements;
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 71;
+				CURRENT_PROJECT_VERSION = 74;
 				DEVELOPMENT_TEAM = GPMXAZ9G5N;
 				ENABLE_BITCODE = NO;
 				INFOPLIST_FILE = hola/Info.plist;
@@ -609,7 +609,7 @@
 				CODE_SIGN_ENTITLEMENTS = hola/hola.entitlements;
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 71;
+				CURRENT_PROJECT_VERSION = 74;
 				DEVELOPMENT_TEAM = GPMXAZ9G5N;
 				INFOPLIST_FILE = hola/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = (

+ 1 - 1
ios/hola/Info.plist

@@ -32,7 +32,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>71</string>
+	<string>74</string>
 	<key>ITSAppUsesNonExemptEncryption</key>
 	<false/>
 	<key>LSApplicationCategoryType</key>

+ 2 - 2
src/pages/clock/ClockMain.tsx

@@ -857,8 +857,8 @@ export default function Page() {
 
                     </View>
                 </Box>
-
-                <Text style={{color:'#fff',fontSize:30}} onClick={goSetting}>notification setting</Text>
+{/* 
+                <Text style={{color:'#fff',fontSize:30}} onClick={goSetting}>notification setting</Text> */}
                 {
                     user.isLogin && records && records.length > 0 && <View className="index_section" style={{ marginTop: -rpxToPx(25 - 12), marginBottom: -rpxToPx(20) }}>
                         <Text className="index_section_title">{t('feature.track_time_duration.record_fast_sleep.header.latest_record')}</Text>

+ 75 - 10
src/pages/notification/setting.tsx

@@ -6,15 +6,36 @@ import Segment from '@/components/navigation/Segment'
 import { useEffect, useState } from "react";
 import { kIsAndroid, rpxToPx } from "@/utils/tools";
 import './setting.scss'
+import { getNotifySettings, postNotifySettings } from "@/services/notifications";
+import { ColorType } from "@/context/themes/color";
 
 export default function Page() {
     const { t } = useTranslation()
     const [segmentIndex, setSegmentIndex] = useState(0)
+    const [notification, setNotification] = useState<any>(null)
+    const [isExtra, setIsExtra] = useState(false)
+    const [isSunrise, setIsSunrise] = useState(false)
+    const [isSunset, setIsSunset] = useState(false)
+    const [isSolarNoon, setIsSolarNoon] = useState(false)
+    const [loaded, setLoaded] = useState(false)
 
     useEffect(() => {
         checkSetting()
+        getSettings()
     }, [])
 
+    function getSettings() {
+        getNotifySettings().then(res => {
+            var dt = (res as any).notification
+            setNotification(dt)
+            setIsExtra(dt.fast_sleep.extra_reminders.in_app == 'ON')
+            setIsSunrise(dt.follow_sun.sunrise.in_app == 'ON')
+            setIsSunset(dt.follow_sun.sunset.in_app == 'ON')
+            setIsSolarNoon(dt.follow_sun.solar_noon.in_app == 'ON')
+            setLoaded(true)
+        })
+    }
+
     function checkSetting() {
         console.log('notification setting begin')
         if (process.env.TARO_ENV == 'rn' && kIsAndroid) {
@@ -27,7 +48,7 @@ export default function Page() {
 
     }
 
-    function goSetting(){
+    function goSetting() {
         if (process.env.TARO_ENV == 'rn' && kIsAndroid) {
             var Jto = require('react-native').NativeModules.NativeBridge;
             Jto.openNotificationSettings()
@@ -42,14 +63,14 @@ export default function Page() {
             <Text className="setting_header">Reminders</Text>
             <View className="setting_cell">
                 <Text className="setting_cell_title" style={{ flex: 1 }}>At your scheduled time</Text>
-                <Text className="setting_cell_value1">On</Text>
+                <Text className="setting_cell_value1">{notification.fast_sleep.reminders.in_app}</Text>
             </View>
             <Text className="setting_footer">A timely reminder so you never miss your scheduled time for fasting.</Text>
         </View>
     }
 
     function pro() {
-        return <ScrollView style={{flex:1}}>
+        return <ScrollView style={{ flex: 1 }}>
             <View className="setting_container">
                 <View className="setting_section">
                     <Text className="setting_section_title">Fasting with/or Sleep</Text>
@@ -63,7 +84,18 @@ export default function Page() {
                 <Text className="setting_header">Extra Reminders</Text>
                 <View className="setting_cell">
                     <Text className="setting_cell_title" style={{ flex: 1 }}>If I missed previous action</Text>
-                    <Switch className="myswitch" />
+                    <Switch className="myswitch" checked={isExtra} color={ColorType.fast} onChange={(e) => {
+                        // setIsMulti(e.detail.value)
+                        postNotifySettings({
+                            notification:{
+                                fast_sleep:{
+                                    extra_reminders:{
+                                        in_app:e.detail.value?'ON':'OFF'
+                                    }
+                                }
+                            }
+                        })
+                    }}/>
                 </View>
                 <Text className="setting_footer">In cases when you missed a previous action, you receive another reminder to log it together with the current action. This gives you extra protection against any streak loss.</Text>
                 <View className="setting_section">
@@ -73,15 +105,48 @@ export default function Page() {
                 <View className="setting_cell_group">
                     <View className="setting_cell_group_item">
                         <Text className="setting_cell_title" style={{ flex: 1 }}>Sunrise</Text>
-                        <Switch className="myswitch" />
+                        <Switch className="myswitch" checked={isSunrise} color={ColorType.fast} onChange={(e) => {
+                        // setIsMulti(e.detail.value)
+                        postNotifySettings({
+                            notification:{
+                                follow_sun:{
+                                    sunrise:{
+                                        in_app:e.detail.value?'ON':'OFF'
+                                    }
+                                }
+                            }
+                        })
+                    }}/>
                     </View>
                     <View className="setting_cell_group_item">
                         <Text className="setting_cell_title" style={{ flex: 1 }}>Sunset</Text>
-                        <Switch className="myswitch" />
+                        <Switch className="myswitch" checked={isSunset} color={ColorType.fast} onChange={(e) => {
+                        // setIsMulti(e.detail.value)
+                        postNotifySettings({
+                            notification:{
+                                follow_sun:{
+                                    sunset:{
+                                        in_app:e.detail.value?'ON':'OFF'
+                                    }
+                                }
+                            }
+                        })
+                    }}/>
                     </View>
                     <View className="setting_cell_group_item">
                         <Text className="setting_cell_title" style={{ flex: 1 }}>Solar Noon</Text>
-                        <Switch className="myswitch" />
+                        <Switch className="myswitch" checked={isSolarNoon} color={ColorType.fast} onChange={(e) => {
+                        // setIsMulti(e.detail.value)
+                        postNotifySettings({
+                            notification:{
+                                follow_sun:{
+                                    solar_noon:{
+                                        in_app:e.detail.value?'ON':'OFF'
+                                    }
+                                }
+                            }
+                        })
+                    }}/>
                     </View>
                 </View>
                 <Text className="setting_footer">Note if live in polar region, during time of Polar Day (Midnight Sun) when the Sun is up all day and during time of Polar Night when the Sun is down all day, the only reminder available is for daily Solar Noon.</Text>
@@ -89,7 +154,7 @@ export default function Page() {
         </ScrollView>
     }
 
-    return <View className="container" style={{flex:1}}>
+    return <View className="container" style={{ flex: 1 }}>
         {/* <View className='setting_segment'>
             <Segment titles={[
                 `Free`,
@@ -103,10 +168,10 @@ export default function Page() {
         </View> */}
 
         {
-            segmentIndex == 1 ? free() : pro()
+            loaded && pro()
         }
         {
-            process.env.TARO_ENV=='rn' && kIsAndroid && <View className="setting_tip" onClick={goSetting}>
+            process.env.TARO_ENV == 'rn' && kIsAndroid && <View className="setting_tip" onClick={goSetting}>
                 <Text className="setting_tip_text">Jump to App's Notifications settings{'>>'}</Text>
             </View>
         }

+ 5 - 1
src/services/http/api.js

@@ -49,7 +49,7 @@ export const API_FAST_SCHEDULES = `${baseUrl}/api/fast/schedules`
 export const API_FAST_CALENDARS = `${baseUrl}/api/fast/calendars/`
 export const API_CLOCK_RECORD_UPDATE = `${baseUrl}/api/clock/records`
 export const API_CLOCK_STREAKS = `${baseUrl}/api/clock/streaks`
-export const API_LOCAL_PUSHES = `${baseUrl}/api/user/local-pushes`
+
 
 
 //track something
@@ -76,3 +76,7 @@ export const API_WORKOUT_RECORDS = `${baseUrl}/api/workout/records`
 
 //permissions
 export const API_WX_PUB_FOLLOWED = `${baseUrl}/api/fast/user/wx-pub-followed`
+
+//notification
+export const API_LOCAL_PUSHES = `${baseUrl}/api/user/local-pushes`
+export const API_NOTIFY_SETTINGS = `${baseUrl}/api/user/notify-settings`

+ 24 - 0
src/services/notifications.tsx

@@ -0,0 +1,24 @@
+import { API_NOTIFY_SETTINGS } from './http/api';
+import { request } from './http/request';
+
+export const getNotifySettings = () => {
+    return new Promise((resolve) => {
+        request({
+            url: API_NOTIFY_SETTINGS, method: 'GET', data: {}
+        }).then(res => {
+            resolve(res);
+            // dispatch(loginSuccess(res));
+        })
+    })
+}
+
+export const postNotifySettings = (params) =>{
+    return new Promise((resolve) => {
+        request({
+            url: API_NOTIFY_SETTINGS, method: 'POST', data: params
+        }).then(res => {
+            resolve(res);
+            // dispatch(loginSuccess(res));
+        })
+    })
+}