Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GeekDIYHome
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
huanglu
GeekDIYHome
Commits
acf9123e
Commit
acf9123e
authored
Jul 27, 2020
by
huanglu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update template
parent
5ffbf57c
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
89 additions
and
54 deletions
+89
-54
global.d.ts
global.d.ts
+8
-3
index.ts
src/navigate/index.ts
+1
-1
index.tsx
src/pages/home/index.tsx
+3
-1
Stack.tsx
src/router/Stack.tsx
+31
-0
Tab.tsx
src/router/Tab.tsx
+41
-0
index.tsx
src/router/index.tsx
+4
-46
routes.tsx
src/router/routes.tsx
+1
-3
stackConfig.ts
src/router/stackConfig.ts
+0
-0
router.ts
src/utils/router.ts
+0
-0
No files found.
global.d.ts
View file @
acf9123e
import
{
StackNavigationProp
}
from
"@react-navigation/stack"
declare
module
"*.png"
;
declare
module
"*.png"
;
declare
module
"*.gif"
;
declare
module
"*.gif"
;
declare
module
"*.jpg"
;
declare
module
"*.jpg"
;
declare
module
"*.jpeg"
;
declare
module
"*.jpeg"
;
declare
module
"*.svg"
;
declare
module
"*.svg"
;
declare
module
'dva-core'
;
declare
module
'dva-*'
;
declare
module
'dva-loading'
declare
module
'dva-immer'
declare
module
'react-native-refresh-list-view'
declare
module
'react-native-refresh-list-view'
type
Action
<
T
>
=
{
type
Action
<
T
>
=
{
...
@@ -41,3 +41,8 @@ type DvaModel<T> = {
...
@@ -41,3 +41,8 @@ type DvaModel<T> = {
[
key
:
string
]:
Effect
[
key
:
string
]:
Effect
}
}
}
}
type
PageProps
=
{
navigation
:
StackNavigationProp
<
any
>
,
dispatch
:
Dispatch
}
src/navigate/index.ts
View file @
acf9123e
import
{
push
,
jump
}
from
"@/utils/route
Util
"
import
{
push
,
jump
}
from
"@/utils/route
r
"
export
default
{
export
default
{
...
...
src/pages/home/index.tsx
View file @
acf9123e
...
@@ -6,6 +6,7 @@ import { TouchableHighlight } from 'react-native-gesture-handler';
...
@@ -6,6 +6,7 @@ import { TouchableHighlight } from 'react-native-gesture-handler';
import
navigate
from
'@/navigate'
;
import
navigate
from
'@/navigate'
;
import
{
useHeaderShow
}
from
'@/hooks'
;
import
{
useHeaderShow
}
from
'@/hooks'
;
import
{
useNavigation
}
from
'@react-navigation/native'
;
import
{
useNavigation
}
from
'@react-navigation/native'
;
import
{
PageProps
}
from
'global'
;
// Idle (普通状态)
// Idle (普通状态)
// HeaderRefreshing (头部菊花转圈圈中)
// HeaderRefreshing (头部菊花转圈圈中)
...
@@ -13,7 +14,7 @@ import { useNavigation } from '@react-navigation/native';
...
@@ -13,7 +14,7 @@ import { useNavigation } from '@react-navigation/native';
// NoMoreData (已加载全部数据)
// NoMoreData (已加载全部数据)
// Failure (加载失败)
// Failure (加载失败)
const
Home
=
(
props
:
any
)
=>
{
const
Home
=
(
props
:
PageProps
)
=>
{
useHeaderShow
(
true
)
useHeaderShow
(
true
)
const
[
list
,
setList
]
=
useState
([
1
,
2
,
3
])
const
[
list
,
setList
]
=
useState
([
1
,
2
,
3
])
...
@@ -22,6 +23,7 @@ const Home = (props: any) => {
...
@@ -22,6 +23,7 @@ const Home = (props: any) => {
useEffect
(()
=>
{
useEffect
(()
=>
{
const
handleFocus
=
()
=>
{
const
handleFocus
=
()
=>
{
props
.
navigation
}
}
navigation
.
addListener
(
'focus'
,
handleFocus
)
navigation
.
addListener
(
'focus'
,
handleFocus
)
return
()
=>
{
return
()
=>
{
...
...
src/router/Stack.tsx
0 → 100644
View file @
acf9123e
import
React
from
'react'
import
{
BaseRouteConfig
}
from
"./routes"
import
{
createStackNavigator
}
from
"@react-navigation/stack"
const
Stack
=
createStackNavigator
()
const
configtabChildren
=
(
components
:
[
BaseRouteConfig
])
=>
{
const
stacks
=
components
.
map
(
com
=>
{
return
(
<
Stack
.
Screen
key=
{
com
.
name
}
name=
{
com
.
name
}
component=
{
com
.
component
as
any
}
options=
{
{
...
com
.
options
||
{}
}
}
/>
)
})
return
stacks
}
export
default
({
routes
}
:
{
routes
:
[
BaseRouteConfig
]})
=>
{
return
(
<
Stack
.
Navigator
>
{
configtabChildren
(
routes
||
[]
as
any
)
}
</
Stack
.
Navigator
>
)
}
\ No newline at end of file
src/router/Tab.tsx
0 → 100644
View file @
acf9123e
import
React
from
'react'
import
{
createBottomTabNavigator
}
from
'@react-navigation/bottom-tabs'
import
routes
from
'./routes'
import
Stack
from
'./Stack'
const
Tab
=
createBottomTabNavigator
()
export
default
()
=>
{
const
tabs
=
(
routes
.
tabs
||
[]).
map
((
tab
,
index
)
=>
{
const
Child
=
()
=>
{
return
<
Stack
routes=
{
tab
.
children
as
any
}
/>
}
return
(
<
Tab
.
Screen
name=
{
tab
.
name
}
key=
{
index
+
'tab'
}
options=
{
({
route
})
=>
{
const
hiddenTabBar
=
(
route
as
any
).
state
&&
(
route
as
any
).
state
.
index
&&
(
route
as
any
).
state
.
index
===
0
;
return
{
tabBarVisible
:
hiddenTabBar
,
...
tab
.
options
||
{},
tabBarBadge
:
tab
.
name
===
'Home'
?
3
:
tab
.
name
===
'About'
?
2
:
1
}
}
}
component=
{
Child
}
/>
)
})
return
(
<
Tab
.
Navigator
tabBarOptions=
{
{
}
}
screenOptions=
{
{
tabBarVisible
:
true
,
}
}
>
{
tabs
}
</
Tab
.
Navigator
>
)
}
\ No newline at end of file
src/router/index.tsx
View file @
acf9123e
import
React
from
'react'
import
React
from
'react'
import
{
createStackNavigator
}
from
'@react-navigation/stack'
import
{
NavigationContainer
}
from
'@react-navigation/native'
import
{
createBottomTabNavigator
}
from
'@react-navigation/bottom-tabs'
import
{
TopStackNavigationRef
}
from
'@/utils/router'
import
{
NavigationContainer
,
getFocusedRouteNameFromRoute
}
from
'@react-navigation/native'
import
Tab
from
'./Tab'
import
{
TopStackNavigationRef
}
from
'@/utils/routeUtil'
import
routes
,
{
BaseRouteConfig
}
from
'./routes'
const
Stack
=
createStackNavigator
()
const
Tab
=
createBottomTabNavigator
()
const
configtabChildren
=
(
components
:
[
BaseRouteConfig
])
=>
{
const
stacks
=
components
.
map
(
com
=>
{
return
(
<
Stack
.
Screen
key=
{
com
.
name
}
name=
{
com
.
name
}
component=
{
com
.
component
as
any
}
options=
{
{
...
com
.
options
||
{}
}
}
/>
)
})
return
stacks
}
const
tabs
=
(
routes
.
tabs
||
[]).
map
((
tab
,
index
)
=>
{
const
Child
=
()
=>
{
return
<
Stack
.
Navigator
>
{
configtabChildren
(
tab
.
children
||
[]
as
any
)
}
</
Stack
.
Navigator
>
}
return
(
<
Tab
.
Screen
name=
{
tab
.
name
}
key=
{
index
+
'tab'
}
options=
{
({
route
})
=>
{
const
routeName
=
getFocusedRouteNameFromRoute
(
route
)
const
hiddenTabBar
=
(
route
as
any
).
state
&&
(
route
as
any
).
state
.
index
&&
(
route
as
any
).
state
.
index
===
0
return
{
tabBarVisible
:
hiddenTabBar
,
...
tab
.
options
||
{}
}
}
}
component=
{
Child
}
/>
)
})
const
RouteApp
=
()
=>
{
const
RouteApp
=
()
=>
{
return
(
return
(
<
NavigationContainer
ref=
{
ref
=>
TopStackNavigationRef
(
ref
)
}
>
<
NavigationContainer
ref=
{
ref
=>
TopStackNavigationRef
(
ref
)
}
>
<
Tab
.
Navigator
tabBarOptions=
{
{
<
Tab
/>
}
}
screenOptions=
{
{
tabBarVisible
:
true
,
}
}
>
{
tabs
}
</
Tab
.
Navigator
>
</
NavigationContainer
>
</
NavigationContainer
>
)
)
}
}
...
...
src/router/routes.tsx
View file @
acf9123e
...
@@ -52,8 +52,7 @@ const routesConfig: {
...
@@ -52,8 +52,7 @@ const routesConfig: {
name
:
'About'
,
name
:
'About'
,
options
:
{
options
:
{
tabBarLabel
:
'About'
,
tabBarLabel
:
'About'
,
tabBarIcon
:
(
props
)
=>
<
View
style=
{
{
width
:
30
,
height
:
30
,
backgroundColor
:
'blue'
}
}
></
View
>,
tabBarIcon
:
(
props
)
=>
<
View
style=
{
{
width
:
30
,
height
:
30
,
backgroundColor
:
'blue'
}
}
></
View
>
tabBarBadge
:
4
},
},
children
:
[
children
:
[
{
{
...
@@ -72,7 +71,6 @@ const routesConfig: {
...
@@ -72,7 +71,6 @@ const routesConfig: {
options
:
{
options
:
{
tabBarLabel
:
'Person'
,
tabBarLabel
:
'Person'
,
tabBarIcon
:
(
props
)
=>
<
View
style=
{
{
width
:
30
,
height
:
30
,
backgroundColor
:
'blue'
}
}
></
View
>,
tabBarIcon
:
(
props
)
=>
<
View
style=
{
{
width
:
30
,
height
:
30
,
backgroundColor
:
'blue'
}
}
></
View
>,
tabBarBadge
:
4
},
},
children
:
[
children
:
[
{
{
...
...
src/router/stackConfig.ts
deleted
100644 → 0
View file @
5ffbf57c
src/utils/route
Util
.ts
→
src/utils/route
r
.ts
View file @
acf9123e
File moved
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