This repository was archived by the owner on Nov 12, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +39
-4
lines changed
Expand file tree Collapse file tree 2 files changed +39
-4
lines changed Original file line number Diff line number Diff line change 66import * as TYPES from './actionTypes' ;
77import SettingsDataDAO from '../dao/SettingsDataDAO' ;
88
9- export function changeColor ( color ) {
9+ export function changeColor ( color , flag = true ) {
10+ if ( flag ) {
11+ let dao = new SettingsDataDAO ( ) ;
12+ dao . saveThemeColor ( color ) ;
13+ }
14+
15+ console . log ( color ) ;
1016 return {
1117 type : TYPES . CHANGE_COLOR ,
1218 color : color
@@ -30,7 +36,7 @@ export function changeShowThumbnail(value, flag=true) {
3036 }
3137}
3238
33- function getShowThumbnailValue ( ) {
39+ function fetchShowThumbnailValue ( ) {
3440 return ( dispatch ) => {
3541 let dao = new SettingsDataDAO ( ) ;
3642 dao . getShowThumbnailValue ( ) . then ( ( result ) => {
@@ -41,8 +47,22 @@ function getShowThumbnailValue() {
4147 } ;
4248}
4349
50+ function fetchThemeColorValue ( ) {
51+ return ( dispatch ) => {
52+ let dao = new SettingsDataDAO ( ) ;
53+ dao . getThemeColorValue ( ) . then ( ( result ) => {
54+ console . log ( 'right' ) ;
55+ dispatch ( changeColor ( result , false ) ) ;
56+ } , ( error ) => {
57+ console . log ( 'wrong' ) ;
58+ dispatch ( changeColor ( error ) ) ;
59+ } ) ;
60+ } ;
61+ }
62+
4463export function initialSettingsStateFacade ( ) {
4564 return ( dispatch ) => {
46- dispatch ( getShowThumbnailValue ( ) ) ;
65+ dispatch ( fetchShowThumbnailValue ( ) ) ;
66+ dispatch ( fetchThemeColorValue ( ) ) ;
4767 }
4868}
Original file line number Diff line number Diff line change 44'use strict' ;
55
66const SHOW_THUMBNAIL = 'showThumbnail' ;
7-
7+ const THEME_COLOR = 'themeColor' ;
88
99import { AsyncStorage } from 'react-native' ;
1010
@@ -29,5 +29,20 @@ export default class SettingsDataDAO{
2929 } ) ;
3030 }
3131
32+ saveThemeColor ( color ) {
33+ AsyncStorage . setItem ( THEME_COLOR , color ) ;
34+ }
35+
36+ getThemeColorValue ( ) {
37+ return new Promise ( ( resolve , reject ) => {
38+ AsyncStorage . getItem ( THEME_COLOR , ( error , result ) => {
39+ if ( ! error && result ) {
40+ resolve ( result ) ;
41+ } else {
42+ reject ( '#1e90ff' ) ;
43+ }
44+ } ) ;
45+ } ) ;
46+ }
3247
3348}
You can’t perform that action at this time.
0 commit comments