Skip to content

Commit

Permalink
Rewrote some parts in the launch process
Browse files Browse the repository at this point in the history
  • Loading branch information
kaulex99 committed Jun 23, 2024
1 parent 3a27ac4 commit 49a1722
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions Modules/WRCore/Sources/WRCore/Globals.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation
import shared
import SwiftUI
import UIKit

public var koin: IosKoinComponent { IosKoinComponent.shared }
Expand Down Expand Up @@ -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
}
}
62 changes: 29 additions & 33 deletions WaiterRobot/Features/Core/DynamicGrid.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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()
}
}
2 changes: 1 addition & 1 deletion WaiterRobot/Features/Login/LoginScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
}
Expand Down
18 changes: 17 additions & 1 deletion WaiterRobot/Features/TableList/TableListScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
57 changes: 38 additions & 19 deletions WaiterRobot/LaunchScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -51,7 +70,7 @@ struct LaunchScreen: View {
}

#Preview {
PreviewView {
LaunchScreen()
}
// PreviewView {
LaunchScreen()
// }
}
47 changes: 47 additions & 0 deletions WaiterRobot/Resources/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Y6W-OH-hqX">
<device id="iPad13_0rounded" orientation="portrait" layout="fullscreen" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="s0d-6b-0kx">
<objects>
<viewController id="Y6W-OH-hqX" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc">
<rect key="frame" x="0.0" y="0.0" width="1032" height="1376"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" insetsLayoutMarginsFromSafeArea="NO" image="logoRounded" translatesAutoresizingMaskIntoConstraints="NO" id="w5j-AB-IDD">
<rect key="frame" x="376" y="548" width="280" height="280"/>
<constraints>
<constraint firstAttribute="height" constant="280" id="aBY-iz-Lzg"/>
<constraint firstAttribute="width" constant="280" id="p7Z-zS-vAS"/>
</constraints>
</imageView>
</subviews>
<viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="w5j-AB-IDD" firstAttribute="centerY" secondItem="5EZ-qb-Rvc" secondAttribute="centerY" id="fLO-J0-fOb"/>
<constraint firstItem="w5j-AB-IDD" firstAttribute="centerX" secondItem="5EZ-qb-Rvc" secondAttribute="centerX" id="oE4-Za-cQd"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="140" y="4"/>
</scene>
</scenes>
<resources>
<image name="logoRounded" width="2048" height="2048"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
2 changes: 1 addition & 1 deletion project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 49a1722

Please sign in to comment.