From 49a17223710412793ca6a530c8b34c14246cf89b Mon Sep 17 00:00:00 2001 From: Alexander Kauer Date: Sun, 23 Jun 2024 22:48:34 +0200 Subject: [PATCH] Rewrote some parts in the launch process --- .../title.colorset/Contents.json | 6 +- Modules/WRCore/Sources/WRCore/Globals.swift | 12 ++++ WaiterRobot/Features/Core/DynamicGrid.swift | 62 +++++++++---------- WaiterRobot/Features/Login/LoginScreen.swift | 2 +- .../Features/TableList/TableListScreen.swift | 18 +++++- WaiterRobot/LaunchScreen.swift | 57 +++++++++++------ WaiterRobot/Resources/LaunchScreen.storyboard | 47 ++++++++++++++ project.yml | 2 +- 8 files changed, 148 insertions(+), 58 deletions(-) create mode 100644 WaiterRobot/Resources/LaunchScreen.storyboard diff --git a/Modules/SharedUI/Sources/SharedUI/Resources/Colors.xcassets/title.colorset/Contents.json b/Modules/SharedUI/Sources/SharedUI/Resources/Colors.xcassets/title.colorset/Contents.json index f810ebf..5fb9a4d 100644 --- a/Modules/SharedUI/Sources/SharedUI/Resources/Colors.xcassets/title.colorset/Contents.json +++ b/Modules/SharedUI/Sources/SharedUI/Resources/Colors.xcassets/title.colorset/Contents.json @@ -5,9 +5,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0x88", - "green" : "0x4C", - "red" : "0x40" + "blue" : "0x47", + "green" : "0x23", + "red" : "0x1B" } }, "idiom" : "universal" diff --git a/Modules/WRCore/Sources/WRCore/Globals.swift b/Modules/WRCore/Sources/WRCore/Globals.swift index a9eb3db..9966014 100644 --- a/Modules/WRCore/Sources/WRCore/Globals.swift +++ b/Modules/WRCore/Sources/WRCore/Globals.swift @@ -1,5 +1,6 @@ import Foundation import shared +import SwiftUI import UIKit public var koin: IosKoinComponent { IosKoinComponent.shared } @@ -36,9 +37,20 @@ public enum WRCore { private static func readFromInfoPlist(withKey key: String) -> String { guard let value = Bundle.main.infoDictionary?[key] as? String else { + print("ERROR") fatalError("Could not find key '\(key)' in info.plist file.") } return value } } + +public extension EnvironmentValues { + var isPreview: Bool { + #if DEBUG + return ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" + #else + return false + #endif + } +} diff --git a/WaiterRobot/Features/Core/DynamicGrid.swift b/WaiterRobot/Features/Core/DynamicGrid.swift index 43d8a06..10f6adc 100644 --- a/WaiterRobot/Features/Core/DynamicGrid.swift +++ b/WaiterRobot/Features/Core/DynamicGrid.swift @@ -67,7 +67,6 @@ public struct DynamicGrid: Layout, Sendable { maxYinRow = 0 } -// print("Will place item \(index) at x:\(x) y:\(y)") subviews[index] .place( at: CGPoint(x: x, y: y), @@ -81,40 +80,37 @@ public struct DynamicGrid: Layout, Sendable { } } +@available(iOS 16.0, *) #Preview { - if #available(iOS 16, *) { - ScrollView { - VStack { - DynamicGrid(horizontalSpacing: 10, verticalSpacing: 10) { - Rectangle() - .foregroundColor(.brown) - .frame(width: 100, height: 50) - Rectangle() - .foregroundColor(.yellow) - .frame(width: 80, height: 20) - Rectangle() - .foregroundColor(.green) - .frame(width: 100, height: 60) - Rectangle() - .foregroundColor(.brown) - .frame(width: 100, height: 50) - Rectangle() - .foregroundColor(.yellow) - .frame(width: 250, height: 20) - Rectangle() - .foregroundColor(.green) - .frame(width: 100, height: 60) - Rectangle() - .foregroundColor(.blue) - .frame(width: 200, height: 50) - Rectangle() - .foregroundColor(.gray) - .frame(width: 200, height: 110) - } + ScrollView { + VStack { + DynamicGrid(horizontalSpacing: 10, verticalSpacing: 10) { + Rectangle() + .foregroundColor(.brown) + .frame(width: 100, height: 50) + Rectangle() + .foregroundColor(.yellow) + .frame(width: 80, height: 20) + Rectangle() + .foregroundColor(.green) + .frame(width: 100, height: 60) + Rectangle() + .foregroundColor(.brown) + .frame(width: 100, height: 50) + Rectangle() + .foregroundColor(.yellow) + .frame(width: 250, height: 20) + Rectangle() + .foregroundColor(.green) + .frame(width: 100, height: 60) + Rectangle() + .foregroundColor(.blue) + .frame(width: 200, height: 50) + Rectangle() + .foregroundColor(.gray) + .frame(width: 200, height: 110) } - .padding() } - } else { - EmptyView() + .padding() } } diff --git a/WaiterRobot/Features/Login/LoginScreen.swift b/WaiterRobot/Features/Login/LoginScreen.swift index 3a366b8..5223892 100644 --- a/WaiterRobot/Features/Login/LoginScreen.swift +++ b/WaiterRobot/Features/Login/LoginScreen.swift @@ -89,7 +89,7 @@ struct LoginScreen: View { .padding() .task { do { - try await Task.sleep(seconds: 2) + try await Task.sleep(seconds: 1) showGetStartedButton = true } catch {} } diff --git a/WaiterRobot/Features/TableList/TableListScreen.swift b/WaiterRobot/Features/TableList/TableListScreen.swift index 2ff6b73..28c960e 100644 --- a/WaiterRobot/Features/TableList/TableListScreen.swift +++ b/WaiterRobot/Features/TableList/TableListScreen.swift @@ -38,7 +38,23 @@ struct TableListScreen: View { } } } - .navigationTitle(CommonApp.shared.settings.eventName) + .toolbar { + ToolbarItem(placement: .principal) { + VStack { + HStack(spacing: 0) { + Text("kellner.") + .textStyle(.h4, textColor: .title) + + Text("team") + .textStyle(.h4, textColor: .palletOrange) + } + + Text(CommonApp.shared.settings.eventName) + .textStyle(.caption1) + .padding(.bottom, 6) + } + } + } .navigationBarTitleDisplayMode(.inline) .animation(.spring, value: viewModel.state.tableGroupsArray) .withViewModel(viewModel, navigator) diff --git a/WaiterRobot/LaunchScreen.swift b/WaiterRobot/LaunchScreen.swift index a2012b7..43f1882 100644 --- a/WaiterRobot/LaunchScreen.swift +++ b/WaiterRobot/LaunchScreen.swift @@ -5,42 +5,61 @@ import SwiftUI import WRCore struct LaunchScreen: View { + @Environment(\.isPreview) private var isPreview + private let minimumOnScreenTimeSeconds = 3.0 - private let device = UIDevice.current.userInterfaceIdiom @State private var startupFinished = false - @State private var isVisible = false + @State private var showProgressView = false var body: some View { ZStack { - VStack { + VStack(spacing: 0) { Image.logoRounded .resizable() .scaledToFit() - .padding() - .frame(maxWidth: 300) + .frame(width: 280, height: 280) + .ignoresSafeArea() + .padding(.bottom, 23) + .transition(.slide) + + if showProgressView { + ProgressView() + .padding() + .foregroundStyle(.green) + } } - .padding() if startupFinished { MainView() } } - .onAppear { + .animation(.spring, value: startupFinished) + .animation(.spring, value: showProgressView) + .task { + defer { + print("Show progress") + showProgressView = true + } + + do { + try await Task.sleep(seconds: 0.1) + } catch {} + } + .task { // This is needed otherwise previews will crash randomly - if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] != "1" { - Task { - async let setup: () = WRCore.setup() - async let delay: () = delay() + if !isPreview { + async let setup: () = WRCore.setup() + async let delay: () = delay() - await setup - await delay + await setup + await delay - startupFinished = true - } + startupFinished = true + } else { + print("Running from preview, skipping init") } } - .animation(.spring, value: startupFinished) } private func delay() async { @@ -51,7 +70,7 @@ struct LaunchScreen: View { } #Preview { - PreviewView { - LaunchScreen() - } +// PreviewView { + LaunchScreen() +// } } diff --git a/WaiterRobot/Resources/LaunchScreen.storyboard b/WaiterRobot/Resources/LaunchScreen.storyboard new file mode 100644 index 0000000..342bbc9 --- /dev/null +++ b/WaiterRobot/Resources/LaunchScreen.storyboard @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/project.yml b/project.yml index 0958039..885b87f 100644 --- a/project.yml +++ b/project.yml @@ -76,7 +76,7 @@ targetTemplates: CFBundleName: "${target_name}" CFBundlePackageType: "$(PRODUCT_BUNDLE_PACKAGE_TYPE)" ITSAppUsesNonExemptEncryption: false - UILaunchScreen: {} + UILaunchStoryboardName: "LaunchScreen.storyboard" NSAppTransportSecurity: NSAllowsLocalNetworking: true NSCameraUsageDescription: "Camera is needed to scan QR-Codes"