Skip to content

Commit

Permalink
Add Feature Button
Browse files Browse the repository at this point in the history
  • Loading branch information
viere1234 committed Nov 6, 2024
1 parent 3a15816 commit 8c6acfb
Show file tree
Hide file tree
Showing 20 changed files with 896 additions and 10 deletions.
52 changes: 52 additions & 0 deletions iosApp/OPass.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
D34BEECB2C723BC6008F9A4C /* OPassApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34BEECA2C723BC6008F9A4C /* OPassApp.swift */; };
D34BEECD2C723BC6008F9A4C /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34BEECC2C723BC6008F9A4C /* ContentView.swift */; };
D34BEECF2C723BC7008F9A4C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D34BEECE2C723BC7008F9A4C /* Assets.xcassets */; };
D35A64EF2CDB00CD0085D41F /* CachedAsyncImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D35A64EE2CDB00CD0085D41F /* CachedAsyncImage.swift */; };
D35A64F12CDB04100085D41F /* FeatureGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = D35A64F02CDB04100085D41F /* FeatureGrid.swift */; };
D35A64FB2CDB0C9F0085D41F /* RobotoCondensed-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D35A64F82CDB0C9F0085D41F /* RobotoCondensed-Regular.ttf */; };
D35A64FC2CDB0C9F0085D41F /* RobotoCondensed-Italic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D35A64F52CDB0C9F0085D41F /* RobotoCondensed-Italic.ttf */; };
D35A64FD2CDB0C9F0085D41F /* RobotoCondensed-LightItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D35A64F72CDB0C9F0085D41F /* RobotoCondensed-LightItalic.ttf */; };
D35A64FE2CDB0C9F0085D41F /* RobotoCondensed-Light.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D35A64F62CDB0C9F0085D41F /* RobotoCondensed-Light.ttf */; };
D35A64FF2CDB0C9F0085D41F /* RobotoCondensed-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D35A64F32CDB0C9F0085D41F /* RobotoCondensed-Bold.ttf */; };
D35A65002CDB0C9F0085D41F /* LICENSE.txt in Resources */ = {isa = PBXBuildFile; fileRef = D35A64F22CDB0C9F0085D41F /* LICENSE.txt */; };
D35A65012CDB0C9F0085D41F /* RobotoCondensed-BoldItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D35A64F42CDB0C9F0085D41F /* RobotoCondensed-BoldItalic.ttf */; };
D39AC9DC2C7B395D00084689 /* SelectEventView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D39AC9DB2C7B395D00084689 /* SelectEventView.swift */; };
D39AC9DE2C7B398E00084689 /* SelectEventViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D39AC9DD2C7B398E00084689 /* SelectEventViewModel.swift */; };
D3B1E7802C774623002DBA07 /* SafariView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3B1E77F2C774623002DBA07 /* SafariView.swift */; };
Expand Down Expand Up @@ -69,6 +78,15 @@
D34BEECA2C723BC6008F9A4C /* OPassApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OPassApp.swift; sourceTree = "<group>"; };
D34BEECC2C723BC6008F9A4C /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
D34BEECE2C723BC7008F9A4C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
D35A64EE2CDB00CD0085D41F /* CachedAsyncImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CachedAsyncImage.swift; sourceTree = "<group>"; };
D35A64F02CDB04100085D41F /* FeatureGrid.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureGrid.swift; sourceTree = "<group>"; };
D35A64F22CDB0C9F0085D41F /* LICENSE.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE.txt; sourceTree = "<group>"; };
D35A64F32CDB0C9F0085D41F /* RobotoCondensed-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "RobotoCondensed-Bold.ttf"; sourceTree = "<group>"; };
D35A64F42CDB0C9F0085D41F /* RobotoCondensed-BoldItalic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "RobotoCondensed-BoldItalic.ttf"; sourceTree = "<group>"; };
D35A64F52CDB0C9F0085D41F /* RobotoCondensed-Italic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "RobotoCondensed-Italic.ttf"; sourceTree = "<group>"; };
D35A64F62CDB0C9F0085D41F /* RobotoCondensed-Light.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "RobotoCondensed-Light.ttf"; sourceTree = "<group>"; };
D35A64F72CDB0C9F0085D41F /* RobotoCondensed-LightItalic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "RobotoCondensed-LightItalic.ttf"; sourceTree = "<group>"; };
D35A64F82CDB0C9F0085D41F /* RobotoCondensed-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "RobotoCondensed-Regular.ttf"; sourceTree = "<group>"; };
D39AC9DB2C7B395D00084689 /* SelectEventView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectEventView.swift; sourceTree = "<group>"; };
D39AC9DD2C7B398E00084689 /* SelectEventViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectEventViewModel.swift; sourceTree = "<group>"; };
D3B1E77F2C774623002DBA07 /* SafariView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -166,6 +184,28 @@
path = OPass;
sourceTree = "<group>";
};
D35A64F92CDB0C9F0085D41F /* Roboto_Condensed */ = {
isa = PBXGroup;
children = (
D35A64F22CDB0C9F0085D41F /* LICENSE.txt */,
D35A64F32CDB0C9F0085D41F /* RobotoCondensed-Bold.ttf */,
D35A64F42CDB0C9F0085D41F /* RobotoCondensed-BoldItalic.ttf */,
D35A64F52CDB0C9F0085D41F /* RobotoCondensed-Italic.ttf */,
D35A64F62CDB0C9F0085D41F /* RobotoCondensed-Light.ttf */,
D35A64F72CDB0C9F0085D41F /* RobotoCondensed-LightItalic.ttf */,
D35A64F82CDB0C9F0085D41F /* RobotoCondensed-Regular.ttf */,
);
path = Roboto_Condensed;
sourceTree = "<group>";
};
D35A64FA2CDB0C9F0085D41F /* Fonts */ = {
isa = PBXGroup;
children = (
D35A64F92CDB0C9F0085D41F /* Roboto_Condensed */,
);
path = Fonts;
sourceTree = "<group>";
};
D39AC9DA2C7B394600084689 /* SelectEvent */ = {
isa = PBXGroup;
children = (
Expand All @@ -180,6 +220,7 @@
children = (
D3B1E77F2C774623002DBA07 /* SafariView.swift */,
D3B1E7812C775E7C002DBA07 /* CenterLabelStyle.swift */,
D35A64EE2CDB00CD0085D41F /* CachedAsyncImage.swift */,
);
path = General;
sourceTree = "<group>";
Expand All @@ -197,6 +238,7 @@
D3E215BD2C723E0B00F7AA4A /* Supporting Files */ = {
isa = PBXGroup;
children = (
D35A64FA2CDB0C9F0085D41F /* Fonts */,
D3C397FF2C73A13A002FFD42 /* OPass.entitlements */,
D3C398002C73A14C002FFD42 /* Info.plist */,
D307A8802C76039D00BB00FB /* GoogleService-Info.plist */,
Expand All @@ -211,6 +253,7 @@
children = (
D3EBBF662C8454E400A49285 /* EventView.swift */,
D3EBBF682C8454EF00A49285 /* EventViewModel.swift */,
D35A64F02CDB04100085D41F /* FeatureGrid.swift */,
);
path = Event;
sourceTree = "<group>";
Expand Down Expand Up @@ -321,6 +364,13 @@
D3C397FE2C73A079002FFD42 /* Localizable.xcstrings in Resources */,
D34BEECF2C723BC7008F9A4C /* Assets.xcassets in Resources */,
D307A8812C76039D00BB00FB /* GoogleService-Info.plist in Resources */,
D35A64FB2CDB0C9F0085D41F /* RobotoCondensed-Regular.ttf in Resources */,
D35A64FC2CDB0C9F0085D41F /* RobotoCondensed-Italic.ttf in Resources */,
D35A64FD2CDB0C9F0085D41F /* RobotoCondensed-LightItalic.ttf in Resources */,
D35A64FE2CDB0C9F0085D41F /* RobotoCondensed-Light.ttf in Resources */,
D35A64FF2CDB0C9F0085D41F /* RobotoCondensed-Bold.ttf in Resources */,
D35A65002CDB0C9F0085D41F /* LICENSE.txt in Resources */,
D35A65012CDB0C9F0085D41F /* RobotoCondensed-BoldItalic.ttf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -382,7 +432,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D35A64F12CDB04100085D41F /* FeatureGrid.swift in Sources */,
D3D1B8A02C7475A00075A747 /* SettingsView.swift in Sources */,
D35A64EF2CDB00CD0085D41F /* CachedAsyncImage.swift in Sources */,
D34BEECD2C723BC6008F9A4C /* ContentView.swift in Sources */,
D3FA31322C8C457800949ECF /* GeneralSettingsView.swift in Sources */,
D3EBBF692C8454EF00A49285 /* EventViewModel.swift in Sources */,
Expand Down
19 changes: 17 additions & 2 deletions iosApp/OPass/Event/EventView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,28 @@ struct EventView: View {
}
}
.analyticsScreen(name: "EventView")
.background(.section)
}

@ViewBuilder
private func eventView(_ config: EventConfig) -> some View {
VStack {
Text(config.name)
Text(config.logoUrl)
CachedAsyncImage(url: URL(string: config.logoUrl)) { phase in
switch phase {
case .empty:
ProgressView()
case .success(let image):
image.resizable().scaledToFit()
default:
Text(config.name)
.font(.system(.largeTitle, design: .rounded))
.fontWeight(.medium)
.fixedSize(horizontal: false, vertical: true)
}
}
.frame(width: UIScreen.main.bounds.width * 0.78, height: UIScreen.main.bounds.width * 0.4)

FeatureGrid(config: config)
}
.onChange(of: eventID) { viewModel.reset() }
}
Expand Down
63 changes: 63 additions & 0 deletions iosApp/OPass/Event/FeatureGrid.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// FeatureGrid.swift
// OPass
//
// Created by Brian Chang on 2024/11/6.
//

import Shared
import SwiftUI

struct FeatureGrid: View {
// MARK: - Variables
let config: EventConfig

// MARK: - Views
var body: some View {
ScrollView {
LazyVGrid(columns: .init(
repeating: .init(spacing: 30, alignment: .top),
count: 4
)) {
ForEach(config.features, id: \.self) { feature in
featureGridItem(feature)
.padding(.bottom, 5)
}
}
}
.padding(.horizontal)
}

@ViewBuilder
private func featureGridItem(_ feature: Feature) -> some View {
VStack {
Button {

} label: {
CachedAsyncImage(url: URL(string: feature.iconUrl ?? "")) { phase in
switch phase {
case .success(let image):
image
.renderingMode(.template)
.interpolation(.none)
.resizable()
.scaledToFill()
default:
Image(systemName: feature.symbol)
.resizable()
.scaledToFill()
.padding(3)
}
}
}
.buttonStyle(.bordered)
.tint(feature.color)

Text(feature.label)
.font(.custom("RobotoCondensed-Regular", size: 11, relativeTo: .caption2))
.fixedSize(horizontal: false, vertical: true)
.multilineTextAlignment(.center)

}
}
}
37 changes: 37 additions & 0 deletions iosApp/OPass/Extension/Shared+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,44 @@
//

import Shared
import SwiftUI

extension Shared.PortalHelper {
static let shared = PortalHelper()
}

extension Shared.Feature {
var symbol: String {
switch self.type {
case .fastPass: return "wallet.pass"
case .schedule: return "scroll"
case .announcement: return "megaphone"
case .puzzle: return "puzzlepiece.extension"
case .ticket: return "ticket"
case .telegram: return "paperplane"
case .im: return "bubble.right"
case .sponsors: return "banknote"
case .staffs: return "person.2"
case .venue: return "map"
case .wifi: return "wifi"
default: return "shippingbox"
}
}

var color: Color {
switch self.type {
case .fastPass: return .blue
case .schedule: return .green
case .announcement: return .orange
case .puzzle: return .blue
case .ticket: return .purple
case .telegram: return .init(red: 89/255, green: 196/255, blue: 189/255)
case .im: return .init(red: 86/255, green: 89/255, blue: 207/255)
case .sponsors: return .yellow
case .staffs: return .gray
case .venue: return .init(red: 87/255, green: 172/255, blue: 225/255)
case .wifi: return .brown
default: return .purple
}
}
}
Loading

0 comments on commit 8c6acfb

Please sign in to comment.