Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

Rev 26 | Rev 33 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 26 Rev 32
Línea 8... Línea 8...
8
import Foundation
8
import Foundation
Línea 9... Línea 9...
9
 
9
 
Línea 10... Línea -...
10
import SwiftUI
-
 
11
 
-
 
12
 
-
 
13
class GridGalleryTabController: ObservableObject {
-
 
14
    @Published var activeTab : Int = 0
-
 
15
 
-
 
16
    func open( tab: Int) {
-
 
17
        activeTab = tab
-
 
18
    }
10
import SwiftUI
Línea 19... Línea 11...
19
}
11
 
20
 
12
 
-
 
13
struct GridGalleryView: View {
Línea 21... Línea -...
21
struct GridGalleryView: View {
-
 
Línea 22... Línea 14...
22
 
14
 
23
    @EnvironmentObject private var networkMonitor : NetworkMonitor
15
    @EnvironmentObject private var networkMonitor : NetworkMonitor
24
    @EnvironmentObject private var appNavigation : AppNavigation
-
 
-
 
16
    @EnvironmentObject private var appNavigation : AppNavigation
Línea 25... Línea 17...
25
    
17
    @ObservedObject private var viewModel : GalleryGridViewModel = GalleryGridViewModel()
Línea 51... Línea 43...
51
 
43
 
52
    var body: some View {
44
    var body: some View {
53
        GeometryReader { geometry in
45
        GeometryReader { geometry in
Línea 54... Línea 46...
54
        ZStack {
46
        ZStack {
55
            
47
            
56
            if self.selectedTab > 0 {
48
            if self.viewModel.hasPrevious()  {
57
                Button(action: {
49
                Button(action: {
Línea -... Línea 50...
-
 
50
                    self.viewModel.previous()
58
                    appData.slideUuidActive = self.viewModel.slides[self.selectedTab - 1].uuid
51
                    self.completeSlide(position: self.viewModel.slideActiveIndex)
59
                    appData.save()
52
                    
60
                    
53
                    appData.slideUuidActive = self.viewModel.slides[self.viewModel.slideActiveIndex].uuid
61
                    self.selectedTab = self.selectedTab - 1
54
                    appData.save()
Línea 62... Línea 55...
62
                }, label: {
55
                }, label: {
Línea 68... Línea 61...
68
                .background(Color("color_button_gallery_background"))
61
                .background(Color("color_button_gallery_background"))
69
                .foregroundColor(Color("color_button_gallery_foreground"))
62
                .foregroundColor(Color("color_button_gallery_foreground"))
70
                    .offset(x: -1 * ((geometry.size.width / 2) - 30), y :  25).zIndex(10000)
63
                    .offset(x: -1 * ((geometry.size.width / 2) - 30), y :  25).zIndex(10000)
71
            }
64
            }
Línea 72... Línea 65...
72
            
65
            
73
            if self.selectedTab < (self.viewModel.slides.count - 1) {
66
            if self.viewModel.hasNext() {
-
 
67
                Button(action: {
-
 
68
        
-
 
69
                    self.viewModel.next()
-
 
70
                    self.completeSlide(position: self.viewModel.slideActiveIndex)
74
                Button(action: {
71
                    
75
                    appData.slideUuidActive = self.viewModel.slides[self.selectedTab + 1].uuid
72
                    appData.slideUuidActive = self.viewModel.slides[self.viewModel.slideActiveIndex].uuid
Línea 76... Línea -...
76
                    appData.save()
-
 
-
 
73
                    appData.save()
77
                    
74
                    
78
                    self.selectedTab = self.selectedTab + 1
75
                    
79
                }, label: {
76
                }, label: {
80
                    Image(systemName: "arrow.right")
77
                    Image(systemName: "arrow.right")
81
                })
78
                })
Línea 115... Línea 112...
115
                .background(networkMonitor.status == .disconnected ? Color("color_network_disconnected_background") : Color("color_app_bar_background"))
112
                .background(networkMonitor.status == .disconnected ? Color("color_network_disconnected_background") : Color("color_app_bar_background"))
Línea 116... Línea 113...
116
        
113
        
Línea -... Línea 114...
-
 
114
        
-
 
115
                Divider().background(networkMonitor.status == .disconnected ? Color("color_network_disconnected_background") : Color("color_app_bar_background"))
-
 
116
                
-
 
117
                CardGalleryView(
-
 
118
                    slideUuid:  self.viewModel.slides[0].uuid
-
 
119
                )
-
 
120
                .environmentObject(appNavigation)
-
 
121
                .transition(.slide)
-
 
122
                .gesture(
-
 
123
                    DragGesture(minimumDistance: 60).onEnded {
-
 
124
                        if $0.startLocation.x > $0.location.x {
-
 
125
                            print("left")
-
 
126
                            if self.viewModel.hasPrevious()  {
-
 
127
                                self.viewModel.previous()
-
 
128
                                self.completeSlide(position: self.viewModel.slideActiveIndex)
-
 
129
                                    
-
 
130
                                appData.slideUuidActive = self.viewModel.slides[self.viewModel.slideActiveIndex].uuid
-
 
131
                                appData.save()
-
 
132
                            }
-
 
133
                        } else if $0.startLocation.x < $0.location.x {
-
 
134
                            print("right")
-
 
135
                            if self.viewModel.hasNext() {
-
 
136
                                self.viewModel.next()
-
 
137
                                self.completeSlide(position: self.viewModel.slideActiveIndex)
-
 
138
                                    
-
 
139
                                appData.slideUuidActive = self.viewModel.slides[self.viewModel.slideActiveIndex].uuid
-
 
140
                                appData.save()
-
 
141
                            }
-
 
142
                        } else {
-
 
143
                            print("none")
-
 
144
                        }
-
 
145
                        
-
 
146
                        
-
 
147
                        
-
 
148
                        
Línea -... Línea 149...
-
 
149
                    })
117
        
150
                
118
                Divider().background(networkMonitor.status == .disconnected ? Color("color_network_disconnected_background") : Color("color_app_bar_background"))
151
                
119
                
152
                
120
                
153
                /*
121
                TabView(selection: self.$selectedTab) {
154
                TabView(selection: self.$selectedTab) {
Línea 148... Línea 181...
148
                        i += 1
181
                        i += 1
149
                    }
182
                    }
Línea 150... Línea 183...
150
                    
183
                    
151
                    self.selectedTab =  position
184
                    self.selectedTab =  position
152
                    completeSlide(position: self.selectedTab)
185
                    completeSlide(position: self.selectedTab)
Línea 153... Línea 186...
153
                }
186
                }*/
-
 
187
       
-
 
188
            }
-
 
189
            .onAppear {
-
 
190
 
-
 
191
                var position : Int = 0
-
 
192
                var i : Int = 0
-
 
193
                while i < self.viewModel.slides.count {
-
 
194
                    if appData.slideUuidActive == self.viewModel.slides[i].uuid {
-
 
195
                        position = i
-
 
196
                    }
-
 
197
                    i += 1
-
 
198
                }
-
 
199
                
Línea 154... Línea 200...
154
       
200
                self.viewModel.slideActiveIndex = position
155
            }
201
            }
156
 
202