Skip to content

Commit

Permalink
Minor Tidy and Welcome 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
viere1234 committed Feb 4, 2024
1 parent e854574 commit 6884423
Show file tree
Hide file tree
Showing 52 changed files with 144 additions and 166 deletions.
8 changes: 0 additions & 8 deletions OPass.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
D39512F5285A174F009B9AE8 /* EventEditView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D39512F4285A174F009B9AE8 /* EventEditView.swift */; };
D39512F8285A370D009B9AE8 /* EKEventStore+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D39512F7285A370D009B9AE8 /* EKEventStore+Extension.swift */; };
D398F68E2A83F4EE00FB2912 /* SettingsDestinations.swift in Sources */ = {isa = PBXBuildFile; fileRef = D398F68D2A83F4EE00FB2912 /* SettingsDestinations.swift */; };
D398F6922A83FD9800FB2912 /* FeatureGridItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D398F6912A83FD9800FB2912 /* FeatureGridItem.swift */; };
D3A00F1F27D837D00097A6AB /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3A00F1E27D837D00097A6AB /* NotificationService.swift */; };
D3A00F2327D837D00097A6AB /* OneSignalNotificationServiceExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = D3A00F1C27D837D00097A6AB /* OneSignalNotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
D3A705612A829334009E5ADF /* EventView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3A705602A829334009E5ADF /* EventView.swift */; };
Expand All @@ -77,7 +76,6 @@
D3C6194D27CF9A7400643D97 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3C6194C27CF9A7400643D97 /* SettingsView.swift */; };
D3C6F60D28634F3B0074B942 /* MarkdownKit in Frameworks */ = {isa = PBXBuildFile; productRef = D3C6F60C28634F3B0074B942 /* MarkdownKit */; };
D3C6F60F286360FC0074B942 /* Markdown.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3C6F60E286360FC0074B942 /* Markdown.swift */; };
D3D0BB242A820F2F00DC4E61 /* FeatureGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3D0BB232A820F2F00DC4E61 /* FeatureGrid.swift */; };
D3D0BB262A8213C300DC4E61 /* RootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3D0BB252A8213C300DC4E61 /* RootView.swift */; };
D3D0BB2A2A82254800DC4E61 /* Router.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3D0BB292A82254800DC4E61 /* Router.swift */; };
D3D0BB2C2A82276800DC4E61 /* RootDestinations.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3D0BB2B2A82276800DC4E61 /* RootDestinations.swift */; };
Expand Down Expand Up @@ -185,7 +183,6 @@
D39512F4285A174F009B9AE8 /* EventEditView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventEditView.swift; sourceTree = "<group>"; };
D39512F7285A370D009B9AE8 /* EKEventStore+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EKEventStore+Extension.swift"; sourceTree = "<group>"; };
D398F68D2A83F4EE00FB2912 /* SettingsDestinations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsDestinations.swift; sourceTree = "<group>"; };
D398F6912A83FD9800FB2912 /* FeatureGridItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureGridItem.swift; sourceTree = "<group>"; };
D3A00F1C27D837D00097A6AB /* OneSignalNotificationServiceExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = OneSignalNotificationServiceExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
D3A00F1E27D837D00097A6AB /* NotificationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = "<group>"; };
D3A00F2027D837D00097A6AB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand All @@ -201,7 +198,6 @@
D3C6194727CF864B00643D97 /* Schedule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Schedule.swift; sourceTree = "<group>"; };
D3C6194C27CF9A7400643D97 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SettingsView.swift; path = OPass/Settings/SettingsView.swift; sourceTree = SOURCE_ROOT; };
D3C6F60E286360FC0074B942 /* Markdown.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Markdown.swift; sourceTree = "<group>"; };
D3D0BB232A820F2F00DC4E61 /* FeatureGrid.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureGrid.swift; sourceTree = "<group>"; };
D3D0BB252A8213C300DC4E61 /* RootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootView.swift; sourceTree = "<group>"; };
D3D0BB292A82254800DC4E61 /* Router.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Router.swift; sourceTree = "<group>"; };
D3D0BB2B2A82276800DC4E61 /* RootDestinations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootDestinations.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -354,8 +350,6 @@
isa = PBXGroup;
children = (
D3A705602A829334009E5ADF /* EventView.swift */,
D3D0BB232A820F2F00DC4E61 /* FeatureGrid.swift */,
D398F6912A83FD9800FB2912 /* FeatureGridItem.swift */,
D3A705652A82A7D9009E5ADF /* FeatureDestinations.swift */,
);
path = Event;
Expand Down Expand Up @@ -770,7 +764,6 @@
D3FE04F32A83FE72009CA4B4 /* ScheduleDestinations.swift in Sources */,
4F35B17C27D3850B0023621F /* Announcement.swift in Sources */,
D3D3789327CE70EE00021FC4 /* EventConfig.swift in Sources */,
D398F6922A83FD9800FB2912 /* FeatureGridItem.swift in Sources */,
D3D3789127CE62EB00021FC4 /* EventListView.swift in Sources */,
D3D0BB262A8213C300DC4E61 /* RootView.swift in Sources */,
D3DA440B2A78110400361D79 /* String+Extension.swift in Sources */,
Expand All @@ -786,7 +779,6 @@
D34012102821349200D07034 /* View+Extension.swift in Sources */,
D30D9CC128B3F68C00C1E489 /* Accessories.swift in Sources */,
D3652A7A2869AF72002AC419 /* AttributedTextImpl+macOS.swift in Sources */,
D3D0BB242A820F2F00DC4E61 /* FeatureGrid.swift in Sources */,
D30D9CC328B3F68C00C1E489 /* SlideOverCard.swift in Sources */,
D3A705662A82A7D9009E5ADF /* FeatureDestinations.swift in Sources */,
D3FBFA67282A93B200DE118E /* SoundManager.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion OPass/AnnouncementView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// OPass
//
// Created by secminhr on 2022/3/5.
// 2023 OPass.
// 2024 OPass.
//

import SwiftUI
Expand Down
2 changes: 1 addition & 1 deletion OPass/Class+Extension/Array+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// OPass
//
// Created by secminhr on 2022/4/23.
// 2023 OPass.
// 2024 OPass.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion OPass/Class+Extension/Collection+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// OPass
//
// Created by 張智堯 on 2022/8/31.
// 2023 OPass.
// 2024 OPass.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion OPass/Class+Extension/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// OPass
//
// Created by 張智堯 on 2022/8/2.
// 2023 OPass.
// 2024 OPass.
//

import SwiftUI
Expand Down
2 changes: 1 addition & 1 deletion OPass/Class+Extension/EKEventStore+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// OPass
//
// Created by 張智堯 on 2022/6/15.
// 2023 OPass.
// 2024 OPass.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion OPass/Class+Extension/NEHotspot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// OPass
//
// Created by 張智堯 on 2022/5/10.
// 2023 OPass.
// 2024 OPass.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion OPass/Class+Extension/SoundManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// OPass
//
// Created by 張智堯 on 2022/5/10.
// 2023 OPass.
// 2024 OPass.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion OPass/Class+Extension/UIApplication+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// OPass
//
// Created by 張智堯 on 2022/7/1.
// 2023 OPass.
// 2024 OPass.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion OPass/Class+Extension/View+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// OPass
//
// Created by 張智堯 on 2022/5/3.
// 2023 OPass.
// 2024 OPass.
//

import SwiftUI
Expand Down
2 changes: 1 addition & 1 deletion OPass/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// OPass
//
// Created by 張智堯 on 2022/2/28.
// 2023 OPass.
// 2024 OPass.
//

import SwiftUI
Expand Down
93 changes: 91 additions & 2 deletions OPass/Event/EventView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@
import SwiftUI

struct EventView: View {

// MARK: - View State

@EnvironmentObject private var store: OPassStore
@EnvironmentObject private var event: EventStore
@EnvironmentObject private var router: Router
@Environment(\.colorScheme) private var colorScheme
@State private var presentWifi = false

// MARK: - Main View

var body: some View {
VStack() {
Expand All @@ -18,16 +26,19 @@ struct EventView: View {
.padding(.bottom)
.frame(
width: UIScreen.main.bounds.width * 0.78,
height: UIScreen.main.bounds.width * 0.4)
height: UIScreen.main.bounds.width * 0.4
)

FeatureGrid()
featureGrid
}
.navigationDestination(for: FeatureDestinations.self) { $0.view }
.background(.sectionBackground)
.navigationBarTitleDisplayMode(.inline)
.toolbar { toolbar }
}

// MARK: - Private Subviews

@ViewBuilder
private var eventLogo: some View {
if let image = store.eventLogo {
Expand All @@ -50,6 +61,57 @@ struct EventView: View {
}
}

private var featureGrid: some View {
ScrollView {
LazyVGrid(columns: .init(
repeating: .init(spacing: 30, alignment: .top),
count: 4
)) {
ForEach(event.avaliableFeatures, id: \.self) { feature in
featureButton(of: feature)
.padding(.bottom, 5)
}
}
}
.padding(.horizontal)
}

private func featureButton(of feature: Feature) -> some View {
VStack {
Button {
featureAction(of: feature)
} label: {
Rectangle()
.aspectRatio(1, contentMode: .fit)
.foregroundColor(.clear)
.overlay {
if let image = feature.iconImage {
image
.renderingMode(.template)
.interpolation(.none)
.resizable()
.scaledToFill()
} else {
Image(systemName: feature.symbol)
.resizable()
.scaledToFill()
.padding(3)
}
}
.padding(.horizontal, 7)
.padding(.vertical, 12)
}
.buttonStyle(.bordered)
.tint(feature.color)

Text(feature.title.localized())
.font(.custom("RobotoCondensed-Regular", size: 11, relativeTo: .caption2))
.multilineTextAlignment(.center)
.fixedSize(horizontal: false, vertical: true)
}
.sheet(isPresented: $presentWifi) { WiFiView(feature: feature) }
}

@ToolbarContentBuilder
private var toolbar: some ToolbarContent {
ToolbarItem(placement: .principal) {
Expand All @@ -64,4 +126,31 @@ struct EventView: View {
}
}
}

// MARK: - Private Helper

private func featureAction(of feature: Feature) {
switch feature.feature {
case .fastpass:
router.forward(FeatureDestinations.fastpass)
case .schedule:
router.forward(FeatureDestinations.schedule)
case .ticket:
router.forward(FeatureDestinations.ticket)
case .announcement:
router.forward(FeatureDestinations.announcement)
case .wifi:
if let wifi = feature.wifi, wifi.count == 1 {
NEHotspot.ConnectWiFi(SSID: wifi[0].ssid, withPass: wifi[0].password)
} else { presentWifi = true }
case .telegram:
if let urlString = feature.url, let url = URL(string: urlString) {
Constants.openInOS(forURL: url)
}
default:
if let url = feature.url(token: event.token, role: event.attendee?.role) {
Constants.openInAppSafari(forURL: url, style: colorScheme) // TODO: Custom Webview
}
}
}
}
27 changes: 0 additions & 27 deletions OPass/Event/FeatureGrid.swift

This file was deleted.

80 changes: 0 additions & 80 deletions OPass/Event/FeatureGridItem.swift

This file was deleted.

2 changes: 1 addition & 1 deletion OPass/EventListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// OPass
//
// Created by 張智堯 on 2022/3/1.
// 2023 OPass.
// 2024 OPass.
//

import SwiftUI
Expand Down
Loading

0 comments on commit 6884423

Please sign in to comment.