@@ -13,7 +13,6 @@ struct ContentView: View {
13
13
@Environment ( \. dismiss) private var dismiss
14
14
15
15
@Query private var items : [ DjangoFilesSession ]
16
- @State private var showSidebarButton : Bool = false
17
16
@State private var showingEditor = false
18
17
@State private var columnVisibility = NavigationSplitViewVisibility . detailOnly
19
18
@State private var selectedServer : DjangoFilesSession ?
@@ -61,7 +60,6 @@ struct ContentView: View {
61
60
}
62
61
}
63
62
}
64
- . toolbar ( removing: !showSidebarButton ? . sidebarToggle : nil )
65
63
} detail: {
66
64
if let server = selectedServer {
67
65
if server. auth {
@@ -70,25 +68,22 @@ struct ContentView: View {
70
68
selectedServer: server,
71
69
columnVisibility: $columnVisibility,
72
70
showingEditor: $showingEditor,
73
- needsRefresh: $needsRefresh,
74
- showSidebarButton: $showSidebarButton
71
+ needsRefresh: $needsRefresh
75
72
)
76
73
. id ( server. url)
77
74
. onAppear {
78
- showSidebarButton = false
79
75
columnVisibility = . detailOnly
80
76
}
77
+ . toolbarVisibility ( . hidden, for: . navigationBar)
81
78
} else {
82
79
LoginView (
83
80
selectedServer: server,
84
81
onLoginSuccess: {
85
82
needsRefresh = true
86
- showSidebarButton = false
87
83
}
88
84
)
89
85
. id ( server. url)
90
86
. onAppear {
91
- showSidebarButton = true
92
87
columnVisibility = . detailOnly
93
88
}
94
89
}
@@ -145,25 +140,16 @@ public struct AuthViewContainer: View {
145
140
@Environment ( \. presentationMode) private var presentationMode : Binding < PresentationMode >
146
141
@Query private var items : [ DjangoFilesSession ]
147
142
143
+ @State private var isAuthViewLoading : Bool = true
144
+
148
145
var viewingSettings : Binding < Bool >
149
146
let selectedServer : DjangoFilesSession
150
147
var columnVisibility : Binding < NavigationSplitViewVisibility >
151
148
var showingEditor : Binding < Bool >
152
149
var needsRefresh : Binding < Bool >
153
- var showSidebarButton : Binding < Bool >
154
150
155
151
@State private var authController : AuthController = AuthController ( )
156
152
157
- var backButton : some View { Button ( action: {
158
- self . presentationMode. wrappedValue. dismiss ( )
159
- } ) {
160
- HStack {
161
- if !UIDevice. current. localizedModel. contains ( " iPad " ) {
162
- Text ( " Server List " )
163
- }
164
- }
165
- }
166
- }
167
153
public var body : some View {
168
154
if viewingSettings. wrappedValue{
169
155
SessionSelector ( session: selectedServer, viewingSelect: viewingSettings)
@@ -172,22 +158,22 @@ public struct AuthViewContainer: View {
172
158
}
173
159
}
174
160
else if selectedServer. url != " " {
175
- ZStack {
176
- Color . djangoFilesBackground. ignoresSafeArea ( )
177
- LoadingView ( ) . frame ( width: 100 , height: 100 )
161
+ Color . djangoFilesBackground. ignoresSafeArea ( )
162
+ . overlay {
178
163
AuthView (
179
164
authController: authController,
180
165
httpsUrl: selectedServer. url,
181
166
doReset: authController. url? . absoluteString ?? " " != selectedServer. url || !selectedServer. auth,
182
167
session: selectedServer
183
168
)
184
169
. onStartedLoading {
170
+ isAuthViewLoading = true
185
171
}
186
172
. onCancelled {
173
+ isAuthViewLoading = false
187
174
dismiss ( )
188
175
}
189
176
. onAppear ( ) {
190
- showSidebarButton. wrappedValue = false
191
177
columnVisibility. wrappedValue = . detailOnly
192
178
if needsRefresh. wrappedValue {
193
179
authController. reset ( )
@@ -197,11 +183,17 @@ public struct AuthViewContainer: View {
197
183
authController. onStartedLoadingAction = {
198
184
}
199
185
186
+ authController. onLoadedAction = {
187
+ isAuthViewLoading = false
188
+
189
+ }
200
190
authController. onCancelledAction = {
191
+ isAuthViewLoading = false
201
192
dismiss ( )
202
193
}
203
194
204
195
authController. onSchemeRedirectAction = {
196
+ isAuthViewLoading = false
205
197
guard let resolve = authController. schemeURL else {
206
198
return
207
199
}
@@ -210,15 +202,13 @@ public struct AuthViewContainer: View {
210
202
if UIDevice . current. userInterfaceIdiom == . phone{
211
203
self . presentationMode. wrappedValue. dismiss ( )
212
204
}
213
- showSidebarButton. wrappedValue = true
214
205
columnVisibility. wrappedValue = . all
215
206
break
216
207
case " serversettings " :
217
208
viewingSettings. wrappedValue = true
218
209
break
219
210
case " logout " :
220
211
selectedServer. auth = false
221
- showSidebarButton. wrappedValue = true
222
212
columnVisibility. wrappedValue = . automatic
223
213
modelContext. insert ( selectedServer)
224
214
do {
@@ -233,11 +223,14 @@ public struct AuthViewContainer: View {
233
223
}
234
224
}
235
225
}
226
+ . overlay {
227
+ if isAuthViewLoading {
228
+ LoadingView ( ) . frame ( width: 100 , height: 100 )
229
+ }
230
+ }
236
231
}
237
- . frame ( maxWidth: . infinity, maxHeight: . infinity)
238
232
. edgesIgnoringSafeArea ( . all)
239
- . navigationTitle ( Text ( " " ) )
240
- . navigationBarHidden ( true )
233
+ . frame ( maxWidth: . infinity, maxHeight: . infinity)
241
234
}
242
235
else {
243
236
Text ( " Loading... " )
0 commit comments