|
|
|
|
@ -8,7 +8,7 @@ |
|
|
|
|
import SwiftUI |
|
|
|
|
import CoreData |
|
|
|
|
import Combine |
|
|
|
|
import CloudKit |
|
|
|
|
//import CloudKit |
|
|
|
|
|
|
|
|
|
class BoringContext : ObservableObject { |
|
|
|
|
|
|
|
|
|
@ -55,7 +55,9 @@ struct ContentView<T : AbstractTimer>: View { |
|
|
|
|
|
|
|
|
|
@Environment(\.managedObjectContext) private var viewContext |
|
|
|
|
|
|
|
|
|
// @StateObject fileprivate var model: TimersModel = TimersModel() |
|
|
|
|
#if os(iOS) |
|
|
|
|
@Environment(\.horizontalSizeClass) private var horizontalSizeClass |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
@FetchRequest( |
|
|
|
|
sortDescriptors: [NSSortDescriptor(keyPath: \T.order, ascending: true)], |
|
|
|
|
@ -69,15 +71,12 @@ struct ContentView<T : AbstractTimer>: View { |
|
|
|
|
|
|
|
|
|
fileprivate let itemSpacing: CGFloat = 10.0 |
|
|
|
|
|
|
|
|
|
private let columns: [GridItem] = [ |
|
|
|
|
GridItem(spacing: 10.0), |
|
|
|
|
GridItem(spacing: 10.0), |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
|
|
|
|
|
let columns: [GridItem] = self._columns() |
|
|
|
|
|
|
|
|
|
GeometryReader { reader in |
|
|
|
|
let width: CGFloat = reader.size.width / 2 - 15.0 |
|
|
|
|
let width: CGFloat = reader.size.width / CGFloat(columns.count) - 15.0 |
|
|
|
|
|
|
|
|
|
VStack { |
|
|
|
|
|
|
|
|
|
@ -188,6 +187,22 @@ struct ContentView<T : AbstractTimer>: View { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileprivate func _columnCount() -> Int { |
|
|
|
|
#if os(iOS) |
|
|
|
|
if horizontalSizeClass == .compact { |
|
|
|
|
return 2 |
|
|
|
|
} else { |
|
|
|
|
return 3 |
|
|
|
|
} |
|
|
|
|
#else |
|
|
|
|
return 3 |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileprivate func _columns() -> [GridItem] { |
|
|
|
|
return (0..<self._columnCount()).map { _ in GridItem(spacing: 10.0) } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// fileprivate func _buildItemsList() { |
|
|
|
|
// |
|
|
|
|
// var spots: [TimerSpot] = [] |
|
|
|
|
|