11import _ from 'lodash' ;
22import React , { Component } from 'react' ;
3- import AsyncStorage from '@react-native-async-storage/async-storage' ;
43import { StyleSheet , I18nManager } from 'react-native' ;
54import { Colors , View , Text , Picker , Incubator , Switch } from 'react-native-ui-lib' ; //eslint-disable-line
65import { navigationData } from './MenuStructure' ;
6+ import Storage , { DEFAULT_SCREEN , IS_RTL } from '../storage' ;
77
88const none = { label : '[None]' , value : '' } ;
99
@@ -28,25 +28,25 @@ class SettingsScreen extends Component {
2828
2929 this . state = {
3030 showRefreshMessage : false ,
31+ isRTL : false ,
3132 screens
3233 } ;
3334 }
3435
35- async UNSAFE_componentWillMount ( ) {
36+ UNSAFE_componentWillMount ( ) {
3637 const { screens} = this . state ;
37- const defaultScreenId = await AsyncStorage . getItem ( 'uilib.defaultScreen' ) ;
38+ const defaultScreenId = Storage . getString ( DEFAULT_SCREEN ) ;
3839 const defaultScreen = _ . find ( screens , { value : defaultScreenId } ) ;
3940
40- const isRTLString = await AsyncStorage . getItem ( 'uilib.isRTL' ) ;
41- const isRTL = isRTLString === 'true' ;
41+ const isRTL = Storage . getBoolean ( IS_RTL ) ;
4242
4343 this . setState ( { defaultScreen, isRTL} ) ;
4444 }
4545
4646 onDirectionChange = ( ) => {
4747 this . setState ( { isRTL : ! this . state . isRTL } , ( ) => {
4848 I18nManager . forceRTL ( this . state . isRTL ) ;
49- AsyncStorage . setItem ( 'uilib.isRTL' , ` ${ this . state . isRTL } ` ) ;
49+ Storage . set ( IS_RTL , this . state . isRTL ) ;
5050 setTimeout ( ( ) => {
5151 this . setState ( { showRefreshMessage : true } ) ;
5252 } , 1000 ) ;
@@ -55,7 +55,7 @@ class SettingsScreen extends Component {
5555
5656 setDefaultScreen = screen => {
5757 this . setState ( { defaultScreen : screen } ) ;
58- AsyncStorage . setItem ( 'uilib.defaultScreen' , screen . value ) ;
58+ Storage . set ( DEFAULT_SCREEN , screen ) ;
5959 setTimeout ( ( ) => {
6060 this . setState ( { showRefreshMessage : true } ) ;
6161 } , 1000 ) ;
0 commit comments