1
1
import { action , makeObservable , observable } from 'mobx' ;
2
+ import { isTouchDevice } from '@/components/shared/utils/screen/responsive' ;
2
3
3
4
export default class UiStore {
4
5
is_mobile = true ;
@@ -7,6 +8,7 @@ export default class UiStore {
7
8
is_chart_layout_default = true ;
8
9
is_dark_mode_on = localStorage . getItem ( 'theme' ) === 'dark' ;
9
10
account_switcher_disabled_message = '' ;
11
+ current_focus = null ;
10
12
show_prompt = false ;
11
13
is_trading_assessment_for_new_user_enabled = false ;
12
14
is_accounts_switcher_on = false ;
@@ -16,20 +18,23 @@ export default class UiStore {
16
18
17
19
constructor ( ) {
18
20
makeObservable ( this , {
19
- show_prompt : observable ,
21
+ account_switcher_disabled_message : observable ,
22
+ current_focus : observable ,
23
+ is_accounts_switcher_on : observable ,
20
24
is_dark_mode_on : observable ,
21
- is_mobile : observable ,
22
25
is_desktop : observable ,
26
+ is_mobile : observable ,
23
27
is_tablet : observable ,
24
- account_switcher_disabled_message : observable ,
25
- setDarkMode : action ,
26
- setDevice : action ,
27
- setAccountSwitcherDisabledMessage : action ,
28
- setPromptHandler : action ,
29
- setIsTradingAssessmentForNewUserEnabled : action . bound ,
30
28
is_trading_assessment_for_new_user_enabled : observable ,
31
- is_accounts_switcher_on : observable ,
29
+ show_prompt : observable ,
30
+ setAccountSwitcherDisabledMessage : action . bound ,
31
+ setCurrentFocus : action . bound ,
32
+ setDarkMode : action . bound ,
33
+ setDevice : action . bound ,
34
+ setPromptHandler : action . bound ,
35
+ setIsTradingAssessmentForNewUserEnabled : action . bound ,
32
36
toggleAccountsDialog : action . bound ,
37
+ toggleOnScreenKeyboard : action . bound ,
33
38
} ) ;
34
39
}
35
40
@@ -61,4 +66,13 @@ export default class UiStore {
61
66
toggleAccountsDialog ( status = ! this . is_accounts_switcher_on ) {
62
67
this . is_accounts_switcher_on = status ;
63
68
}
69
+
70
+ toggleOnScreenKeyboard ( ) {
71
+ this . is_onscreen_keyboard_active = this . current_focus !== null && this . is_mobile && isTouchDevice ( ) ;
72
+ }
73
+
74
+ setCurrentFocus ( value ) {
75
+ this . current_focus = value ;
76
+ this . toggleOnScreenKeyboard ( ) ;
77
+ }
64
78
}
0 commit comments