1
1
import React from "react"
2
2
import { Page , Toolbar } from "@mmrl/ui"
3
3
import { useActivity , useNativeFileStorage , useStrings } from "@mmrl/hooks"
4
+ import { withRequireNewVersion } from "@mmrl/hoc"
4
5
import {
5
- ArrowBackIosRounded ,
6
- DeleteRounded ,
7
- AddRounded
8
- } from "@mui/icons-material" ;
6
+ ArrowBackIosRounded ,
7
+ DeleteRounded ,
8
+ AddRounded
9
+ } from "@mui/icons-material"
9
10
import {
10
- List ,
11
- ListItem ,
12
- ListItemText ,
13
- ListSubheader ,
14
- IconButton ,
15
- Card ,
16
- CardContent ,
17
- Typography ,
18
- Grid ,
19
- Dialog ,
20
- DialogActions ,
21
- DialogContent ,
22
- DialogContentText ,
23
- DialogTitle ,
24
- TextField ,
25
- Button ,
11
+ List ,
12
+ ListItem ,
13
+ ListItemText ,
14
+ ListSubheader ,
15
+ IconButton ,
16
+ Card ,
17
+ CardContent ,
18
+ Typography ,
19
+ Grid ,
20
+ Dialog ,
21
+ DialogActions ,
22
+ DialogContent ,
23
+ DialogContentText ,
24
+ DialogTitle ,
25
+ TextField ,
26
+ Button ,
26
27
} from "@mui/material"
27
28
28
- const info = include ( "info .json")
29
+ const info = require ( path . resolve ( __modpath , "update .json") )
29
30
30
- export default ( ) => {
31
- const [ repos , setRepos ] = useNativeFileStorage ( "/data/adb/mmrl/repos.json" , [
32
- "https://magisk-modules-alt-repo.github.io/json-v2/json/modules.json" ,
33
- "https://gr.dergoogler.com/gmr/json/modules.json"
34
- ] , { loader : "json" } )
31
+ const App = ( ) => {
32
+ const [ repos , setRepos ] = useNativeFileStorage ( "/data/adb/mmrl/repos.json" , [
33
+ "https://magisk-modules-alt-repo.github.io/json-v2/json/modules.json" ,
34
+ "https://gr.dergoogler.com/gmr/json/modules.json"
35
+ ] , { loader : "json" } )
35
36
36
- const { context } = useActivity ( )
37
- const { strings } = useStrings ( )
37
+ const { context } = useActivity ( )
38
+ const { strings } = useStrings ( )
38
39
39
40
40
- const [ open , setOpen ] = React . useState ( false )
41
- const [ repoLink , setRepoLink ] = React . useState ( "" )
42
- const handleDialogOpen = ( ) => setOpen ( true )
43
- const handleDialogClose = ( ) => { setOpen ( false ) , setRepoLink ( "" ) }
44
- const handleRepoLinkChange = ( e ) => setRepoLink ( e . target . value )
41
+ const [ open , setOpen ] = React . useState ( false )
42
+ const [ repoLink , setRepoLink ] = React . useState ( "" )
43
+ const handleDialogOpen = ( ) => setOpen ( true )
44
+ const handleDialogClose = ( ) => { setOpen ( false ) , setRepoLink ( "" ) }
45
+ const handleRepoLinkChange = ( e ) => setRepoLink ( e . target . value )
45
46
46
47
47
- const renderToolbar = React . useCallback ( ( ) => {
48
- return (
49
- < Toolbar
50
- modifier = "noshadow"
51
- sx = { {
52
- background : "#ba420e" ,
53
- background : "linear-gradient(22deg, #a63012 0%, #fc9e58 100%)" ,
54
- } } >
55
- < Toolbar . Left >
56
- < Toolbar . Button icon = { ArrowBackIosRounded } onClick = { context . popPage } />
57
- </ Toolbar . Left >
58
- < Toolbar . Center > Command line interface config</ Toolbar . Center >
59
- < Toolbar . Right >
60
- < Toolbar . Button icon = { AddRounded } onClick = { handleDialogOpen } />
61
- </ Toolbar . Right >
62
- </ Toolbar >
63
- )
64
- } , [ ] )
48
+ const renderToolbar = React . useCallback ( ( ) => {
49
+ return (
50
+ < Toolbar
51
+ modifier = "noshadow"
52
+ sx = { {
53
+ background : "#ba420e" ,
54
+ background : "linear-gradient(22deg, #a63012 0%, #fc9e58 100%)" ,
55
+ } } >
56
+ < Toolbar . Left >
57
+ < Toolbar . Button icon = { ArrowBackIosRounded } onClick = { context . popPage } />
58
+ </ Toolbar . Left >
59
+ < Toolbar . Center > Command line interface config</ Toolbar . Center >
60
+ < Toolbar . Right >
61
+ < Toolbar . Button icon = { AddRounded } onClick = { handleDialogOpen } />
62
+ </ Toolbar . Right >
63
+ </ Toolbar >
64
+ )
65
+ } , [ ] )
65
66
66
67
67
- return (
68
- < Page renderToolbar = { renderToolbar } >
69
- < Card sx = { { m : 1 } } >
70
- < CardContent >
71
- < Grid container rowSpacing = { 0 } columnSpacing = { 0 } fullWidth >
72
- < Grid item xs = { 5 } >
73
- < Typography variant = "caption" > Author:</ Typography >
74
- </ Grid >
75
- < Grid item xs = { 5 } >
76
- < Typography variant = "caption" > { info . author } </ Typography >
77
- </ Grid >
78
- < Grid item xs = { 5 } >
79
- < Typography variant = "caption" > Version:</ Typography >
80
- </ Grid >
81
- < Grid item xs = { 5 } >
82
- < Typography variant = "caption" > { info . version } ({ info . versionCode } )</ Typography >
83
- </ Grid >
84
- < Grid item xs = { 5 } >
85
- < Typography variant = "caption" > Rust version:</ Typography >
86
- </ Grid >
87
- < Grid item xs = { 5 } >
88
- < Typography variant = "caption" > { info . rustVersion } </ Typography >
89
- </ Grid >
90
- < Grid item xs = { 5 } >
91
- < Typography variant = "caption" > Build date:</ Typography >
92
- </ Grid >
93
- < Grid item xs = { 5 } >
94
- < Typography variant = "caption" > { info . buildDate } </ Typography >
95
- </ Grid >
96
- </ Grid >
97
- </ CardContent >
98
- </ Card >
68
+ return (
69
+ < Page renderToolbar = { renderToolbar } >
70
+ < Card sx = { { m : 1 } } >
71
+ < CardContent >
72
+ < Grid container rowSpacing = { 0 } columnSpacing = { 0 } fullWidth >
73
+ < Grid item xs = { 5 } >
74
+ < Typography variant = "caption" > Author:</ Typography >
75
+ </ Grid >
76
+ < Grid item xs = { 5 } >
77
+ < Typography variant = "caption" > { info . author } </ Typography >
78
+ </ Grid >
79
+ < Grid item xs = { 5 } >
80
+ < Typography variant = "caption" > Version:</ Typography >
81
+ </ Grid >
82
+ < Grid item xs = { 5 } >
83
+ < Typography variant = "caption" > { info . version } ({ info . versionCode } )</ Typography >
84
+ </ Grid >
85
+ < Grid item xs = { 5 } >
86
+ < Typography variant = "caption" > Rust version:</ Typography >
87
+ </ Grid >
88
+ < Grid item xs = { 5 } >
89
+ < Typography variant = "caption" > { info . rustVersion } </ Typography >
90
+ </ Grid >
91
+ < Grid item xs = { 5 } >
92
+ < Typography variant = "caption" > Build date:</ Typography >
93
+ </ Grid >
94
+ < Grid item xs = { 5 } >
95
+ < Typography variant = "caption" > { info . buildDate } </ Typography >
96
+ </ Grid >
97
+ </ Grid >
98
+ </ CardContent >
99
+ </ Card >
99
100
100
- < List subheader = { < ListSubheader > Installed repositories</ ListSubheader > } >
101
- { repos . map ( ( repo ) => {
102
- const handleDelete = ( ) => {
103
- setRepos ( ( rep ) => rep . filter ( ( remv ) => remv != repo ) )
104
- }
105
- return (
106
- < ListItem secondaryAction = {
107
- < IconButton edge = "end" onClick = { handleDelete } >
108
- < DeleteRounded />
109
- </ IconButton >
110
- } >
111
- < ListItemText primary = { repo } />
112
- </ ListItem >
113
- )
114
- } ) }
115
- </ List >
101
+ < List subheader = { < ListSubheader > Installed repositories</ ListSubheader > } >
102
+ { repos . map ( ( repo ) => {
103
+ const handleDelete = ( ) => {
104
+ setRepos ( ( rep ) => rep . filter ( ( remv ) => remv != repo ) )
105
+ }
106
+ return (
107
+ < ListItem secondaryAction = {
108
+ < IconButton edge = "end" onClick = { handleDelete } >
109
+ < DeleteRounded />
110
+ </ IconButton >
111
+ } >
112
+ < ListItemText primary = { repo } />
113
+ </ ListItem >
114
+ )
115
+ } ) }
116
+ </ List >
116
117
117
118
118
- < Dialog open = { open } onClose = { handleDialogOpen } >
119
- < DialogTitle > { strings ( "add_repository" ) } </ DialogTitle >
120
- < DialogContent >
121
- < DialogContentText > { strings ( "add_repository_description" ) } </ DialogContentText >
122
- < TextField
123
- autoFocus
124
- name = "repo_link"
125
- fullWidth
126
- margin = "dense"
127
- type = "text"
128
- label = { "Modules link" }
129
- value = { repoLink }
130
- variant = "outlined"
131
- onChange = { handleRepoLinkChange }
132
- />
133
- </ DialogContent >
134
- < DialogActions >
135
- < Button onClick = { handleDialogClose } > { strings ( "cancel" ) } </ Button >
136
- < Button
137
- onClick = { ( ) => {
138
- if ( ! repos . some ( ( r ) => r === repoLink ) ) {
139
- setRepos ( ( p ) => [ ...p , repoLink ] )
140
- handleDialogClose ( )
141
- }
142
- } } >
143
- { strings ( "add" ) }
144
- </ Button >
145
- </ DialogActions >
146
- </ Dialog >
147
- </ Page >
148
- )
149
- }
119
+ < Dialog open = { open } onClose = { handleDialogOpen } >
120
+ < DialogTitle > { strings ( "add_repository" ) } </ DialogTitle >
121
+ < DialogContent >
122
+ < DialogContentText > { strings ( "add_repository_description" ) } </ DialogContentText >
123
+ < TextField
124
+ autoFocus
125
+ name = "repo_link"
126
+ fullWidth
127
+ margin = "dense"
128
+ type = "text"
129
+ label = { "Modules link" }
130
+ value = { repoLink }
131
+ variant = "outlined"
132
+ onChange = { handleRepoLinkChange }
133
+ />
134
+ </ DialogContent >
135
+ < DialogActions >
136
+ < Button onClick = { handleDialogClose } > { strings ( "cancel" ) } </ Button >
137
+ < Button
138
+ onClick = { ( ) => {
139
+ if ( ! repos . some ( ( r ) => r === repoLink ) ) {
140
+ setRepos ( ( p ) => [ ...p , repoLink ] )
141
+ handleDialogClose ( )
142
+ }
143
+ } } >
144
+ { strings ( "add" ) }
145
+ </ Button >
146
+ </ DialogActions >
147
+ </ Dialog >
148
+ </ Page >
149
+ )
150
+ }
151
+
152
+ export default withRequireNewVersion ( {
153
+ versionCode : 21918 ,
154
+ component : App ,
155
+ } ) ;
0 commit comments