Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beasy-mobile
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
G
beasy-mobile
Commits
972b3326
Commit
972b3326
authored
May 27, 2024
by
G
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed the name of the context to ModalsManager
parent
7a8a889d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
28 deletions
+47
-28
App.tsx
App.tsx
+15
-12
ModalsManagerContext.tsx
src/contexts/ModalsManagerContext.tsx
+32
-16
No files found.
App.tsx
View file @
972b3326
import
{
ModalsManagerProvider
}
from
"@/contexts/ModalsManagerContext"
;
import
{
UserAuthenticationContextProvider
}
from
"@/contexts/UserAuthenticationContext"
;
import
{
UserAuthenticationContextProvider
}
from
"@/contexts/UserAuthenticationContext"
;
import
AppMainStackNavigator
from
"@/navigations/AppMainStackNavigator"
;
import
AppMainStackNavigator
from
"@/navigations/AppMainStackNavigator"
;
import
theme
from
"@/themes/Theme"
;
import
theme
from
"@/themes/Theme"
;
...
@@ -13,21 +14,23 @@ export default function App() {
...
@@ -13,21 +14,23 @@ export default function App() {
log
.
verbose
(
"App started..."
);
log
.
verbose
(
"App started..."
);
return
(
return
(
<
ThemeProvider
theme=
{
theme
}
>
<
ThemeProvider
theme=
{
theme
}
>
<
SafeAreaProvider
>
<
ModalsManagerProvider
>
<
NavigationContainer
>
<
SafeAreaProvider
>
<
ProvideQueryClient
>
<
NavigationContainer
>
<
UserAuthenticationContextProvider
>
<
ProvideQueryClient
>
{
/* <View style={styles.container}> */
}
<
UserAuthenticationContextProvider
>
{
/* <SafeAreaProvider>
{
/* <View style={styles.container}> */
}
{
/* <SafeAreaProvider>
<StatusBar style="auto" />
<StatusBar style="auto" />
<UserLoginScreen />
<UserLoginScreen />
</SafeAreaProvider> */
}
</SafeAreaProvider> */
}
<
AppMainStackNavigator
/>
<
AppMainStackNavigator
/>
{
/* </View> */
}
{
/* </View> */
}
</
UserAuthenticationContextProvider
>
</
UserAuthenticationContextProvider
>
</
ProvideQueryClient
>
</
ProvideQueryClient
>
</
NavigationContainer
>
</
NavigationContainer
>
</
SafeAreaProvider
>
</
SafeAreaProvider
>
</
ModalsManagerProvider
>
</
ThemeProvider
>
</
ThemeProvider
>
);
);
}
}
src/contexts/
Overlay
.tsx
→
src/contexts/
ModalsManagerContext
.tsx
View file @
972b3326
...
@@ -3,36 +3,52 @@ import LoadingModal from "@components/modals/LoadingModal";
...
@@ -3,36 +3,52 @@ import LoadingModal from "@components/modals/LoadingModal";
import
{
createContext
,
useContext
,
useState
}
from
"react"
;
import
{
createContext
,
useContext
,
useState
}
from
"react"
;
import
{
View
}
from
"react-native"
;
import
{
View
}
from
"react-native"
;
export
interface
IoverlayContext
{
export
interface
ImodalsManagerContext
{
showOverlay
():
void
;
showLoadingModal
():
void
;
hideOverlay
():
void
;
closeLoadingModal
():
void
;
showErrorModal
():
void
;
closeErrorModal
():
void
;
}
}
export
const
OverlayContext
=
createContext
<
IoverlayContext
>
({
export
const
ModalsManagerContext
=
createContext
<
ImodalsManagerContext
>
({
showOverlay
:
()
=>
{},
showLoadingModal
:
()
=>
{},
hideOverlay
:
()
=>
{},
closeLoadingModal
:
()
=>
{},
showErrorModal
:
()
=>
{},
closeErrorModal
:
()
=>
{},
});
});
export
const
Overlay
Provider
=
({
children
}:
{
children
:
React
.
ReactNode
})
=>
{
export
const
ModalsManager
Provider
=
({
children
}:
{
children
:
React
.
ReactNode
})
=>
{
const
[
showBackdrop
,
setShowBackdrop
]
=
useState
(
tru
e
);
const
[
showBackdrop
,
setShowBackdrop
]
=
useState
(
fals
e
);
const
[
loadingModalVisible
,
setLoadingModalVisible
]
=
useState
(
false
);
const
[
loadingModalVisible
,
setLoadingModalVisible
]
=
useState
(
false
);
const
[
errorModalVisible
,
setErrorModalVisible
]
=
useState
(
tru
e
);
const
[
errorModalVisible
,
setErrorModalVisible
]
=
useState
(
fals
e
);
const
show
Overlay
=
()
=>
{
const
show
LoadingModal
=
()
=>
{
setShowBackdrop
(
true
);
setShowBackdrop
(
true
);
setLoadingModalVisible
(
true
);
setLoadingModalVisible
(
true
);
};
};
const
hideOverlay
=
()
=>
{
const
closeLoadingModal
=
()
=>
{
setShowBackdrop
(
false
);
setShowBackdrop
(
false
);
setLoadingModalVisible
(
false
);
setLoadingModalVisible
(
false
);
};
};
const
showErrorModal
=
()
=>
{
setShowBackdrop
(
true
);
setErrorModalVisible
(
true
);
};
const
closeErrorModal
=
()
=>
{
setShowBackdrop
(
false
);
setErrorModalVisible
(
false
);
};
return
(
return
(
<
Overlay
Context
.
Provider
<
ModalsManager
Context
.
Provider
value=
{
{
value=
{
{
showOverlay
,
showLoadingModal
,
hideOverlay
,
closeLoadingModal
,
showErrorModal
,
closeErrorModal
,
}
}
}
}
>
>
{
children
}
{
children
}
...
@@ -40,12 +56,12 @@ export const OverlayProvider = ({ children }: { children: React.ReactNode }) =>
...
@@ -40,12 +56,12 @@ export const OverlayProvider = ({ children }: { children: React.ReactNode }) =>
{
loadingModalVisible
&&
<
LoadingModal
/>
}
{
loadingModalVisible
&&
<
LoadingModal
/>
}
{
errorModalVisible
&&
<
ErrorModal
/>
}
{
errorModalVisible
&&
<
ErrorModal
/>
}
</
Overlay
Context
.
Provider
>
</
ModalsManager
Context
.
Provider
>
);
);
};
};
export
const
useOverlayContext
=
()
=>
{
export
const
useOverlayContext
=
()
=>
{
return
useContext
(
Overlay
Context
);
return
useContext
(
ModalsManager
Context
);
};
};
const
OverlayBackdrop
=
()
=>
{
const
OverlayBackdrop
=
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment