Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gaohuaxue-mobile-app
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
赵振东
gaohuaxue-mobile-app
Commits
66f9e491
Commit
66f9e491
authored
Nov 24, 2022
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 搬运主题相关
parent
af6ca198
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
3 deletions
+33
-3
App.tsx
src/App.tsx
+3
-1
useColorScheme.ts
src/hooks/useColorScheme.ts
+11
-0
RootNavigationContainer.tsx
src/routers/RootNavigationContainer.tsx
+19
-2
No files found.
src/App.tsx
View file @
66f9e491
...
...
@@ -11,12 +11,14 @@
import
React
from
'react'
;
import
RootNavigationContainer
from
'./routers/RootNavigationContainer'
;
import
{
storage
}
from
'./utils/storage'
;
import
useColorScheme
from
'./hooks/useColorScheme'
;
//创建全局属性,任意位置都可以调用该实例
global
.
storage
=
storage
;
const
App
=
()
=>
{
return
<
RootNavigationContainer
/>;
const
colorScheme
=
useColorScheme
();
return
<
RootNavigationContainer
colorScheme=
{
colorScheme
}
/>;
};
export
default
App
;
src/hooks/useColorScheme.ts
0 → 100755
View file @
66f9e491
import
{
ColorSchemeName
,
useColorScheme
as
_useColorScheme
,
}
from
'react-native'
;
// The useColorScheme value is always either light or dark, but the built-in
// type suggests that it can be null. This will not happen in practice, so this
// makes it a bit easier to work with.
export
default
function
useColorScheme
():
NonNullable
<
ColorSchemeName
>
{
return
_useColorScheme
()
as
NonNullable
<
ColorSchemeName
>
;
}
src/routers/RootNavigationContainer.tsx
View file @
66f9e491
import
*
as
React
from
'react'
;
import
{
ColorSchemeName
}
from
'react-native'
;
import
{
NavigationContainer
}
from
'@react-navigation/native'
;
import
{
createNativeStackNavigator
}
from
'@react-navigation/native-stack'
;
import
{
RootStackParamList
}
from
'./types'
;
import
{
ROUTERS
as
SCREEN
}
from
'./routers'
;
import
Theme
from
'../constants/theme'
;
const
RootStack
=
createNativeStackNavigator
<
RootStackParamList
>
();
const
SCREEN_NAMES
=
Object
.
keys
(
SCREEN
)
as
(
keyof
typeof
SCREEN
)[];
const
RootNavigationContainer
=
()
=>
{
interface
Iprops
{
colorScheme
:
ColorSchemeName
;
}
const
RootNavigationContainer
:
React
.
FC
<
Iprops
>
=
props
=>
{
const
{
colorScheme
}
=
props
;
const
CurrentTheme
=
()
=>
{
/** 默认模板名称 */
const
themeName
=
'science'
;
if
(
colorScheme
===
'dark'
)
{
// return Theme.dark
}
return
Theme
[
themeName
];
};
return
(
<
NavigationContainer
>
<
NavigationContainer
theme=
{
CurrentTheme
()
}
>
<
RootStack
.
Navigator
screenOptions=
{
{
headerTitleAlign
:
'center'
,
...
...
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