Skip to content

Commit 4bbbe70

Browse files
committed
iOS: Add Bulr effect
1 parent a61269d commit 4bbbe70

File tree

6 files changed

+82
-6
lines changed

6 files changed

+82
-6
lines changed

iosApp/OPass.xcodeproj/project.pbxproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
D300355C2C85E31A0049B7B3 /* Shared+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D300355B2C85E31A0049B7B3 /* Shared+Extension.swift */; };
11+
D30235DB2CDC7AA80033D599 /* BlurView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D30235DA2CDC7AA80033D599 /* BlurView.swift */; };
1112
D307A8812C76039D00BB00FB /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = D307A8802C76039D00BB00FB /* GoogleService-Info.plist */; };
1213
D307A8842C76055F00BB00FB /* FirebaseAnalyticsWithoutAdIdSupport in Frameworks */ = {isa = PBXBuildFile; productRef = D307A8832C76055F00BB00FB /* FirebaseAnalyticsWithoutAdIdSupport */; };
1314
D307A8862C76055F00BB00FB /* FirebaseAppCheck in Frameworks */ = {isa = PBXBuildFile; productRef = D307A8852C76055F00BB00FB /* FirebaseAppCheck */; };
@@ -72,6 +73,7 @@
7273

7374
/* Begin PBXFileReference section */
7475
D300355B2C85E31A0049B7B3 /* Shared+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Shared+Extension.swift"; sourceTree = "<group>"; };
76+
D30235DA2CDC7AA80033D599 /* BlurView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlurView.swift; sourceTree = "<group>"; };
7577
D307A8802C76039D00BB00FB /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
7678
D307A8922C760F8E00BB00FB /* AppearanceSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppearanceSettingsView.swift; sourceTree = "<group>"; };
7779
D34BEEC72C723BC6008F9A4C /* OPass.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OPass.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -178,7 +180,7 @@
178180
D3EBBF652C8454D700A49285 /* Event */,
179181
D39AC9DA2C7B394600084689 /* SelectEvent */,
180182
D307A8912C760F5100BB00FB /* Settings */,
181-
D3B1E77E2C774609002DBA07 /* General */,
183+
D3B1E77E2C774609002DBA07 /* Common */,
182184
D300355A2C85E3010049B7B3 /* Extension */,
183185
);
184186
path = OPass;
@@ -215,14 +217,15 @@
215217
path = SelectEvent;
216218
sourceTree = "<group>";
217219
};
218-
D3B1E77E2C774609002DBA07 /* General */ = {
220+
D3B1E77E2C774609002DBA07 /* Common */ = {
219221
isa = PBXGroup;
220222
children = (
223+
D30235DA2CDC7AA80033D599 /* BlurView.swift */,
221224
D3B1E77F2C774623002DBA07 /* SafariView.swift */,
222225
D3B1E7812C775E7C002DBA07 /* CenterLabelStyle.swift */,
223226
D35A64EE2CDB00CD0085D41F /* CachedAsyncImage.swift */,
224227
);
225-
path = General;
228+
path = Common;
226229
sourceTree = "<group>";
227230
};
228231
D3C398062C73A190002FFD42 /* OneSignalNotificationServiceExtension */ = {
@@ -434,6 +437,7 @@
434437
files = (
435438
D35A64F12CDB04100085D41F /* FeatureGrid.swift in Sources */,
436439
D3D1B8A02C7475A00075A747 /* SettingsView.swift in Sources */,
440+
D30235DB2CDC7AA80033D599 /* BlurView.swift in Sources */,
437441
D35A64EF2CDB00CD0085D41F /* CachedAsyncImage.swift in Sources */,
438442
D34BEECD2C723BC6008F9A4C /* ContentView.swift in Sources */,
439443
D3FA31322C8C457800949ECF /* GeneralSettingsView.swift in Sources */,

iosApp/OPass/Common/BlurView.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// BlurView.swift
3+
// OPass
4+
//
5+
// Created by Brian Chang on 2024/11/7.
6+
// 2024 OPass.
7+
//
8+
9+
import SwiftUI
10+
11+
12+
struct BlurView: UIViewRepresentable {
13+
var style: UIBlurEffect.Style = .dark
14+
15+
func makeUIView(context: Context) -> UIVisualEffectView {
16+
return UIVisualEffectView(effect: UIBlurEffect(style: style))
17+
}
18+
19+
func updateUIView(_ uiView: UIVisualEffectView, context: Context) {
20+
uiView.effect = UIBlurEffect(style: style)
21+
}
22+
}

iosApp/OPass/Event/EventView.swift

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ struct EventView: View {
1414
// MARK: - Variable
1515
@State private var viewModel = EventViewModel()
1616

17+
@Environment(\.colorScheme) private var colorScheme
1718
@AppStorage("EventID") private var eventID = ""
1819

1920
// MARK: - View
@@ -31,7 +32,21 @@ struct EventView: View {
3132

3233
@ViewBuilder
3334
private func eventView(_ config: EventConfig) -> some View {
34-
VStack {
35+
ZStack(alignment: .top) {
36+
ScrollView {
37+
LazyVGrid(columns: .init(
38+
repeating: .init(spacing: 30, alignment: .top),
39+
count: 4
40+
)) {
41+
ForEach(config.features, id: \.self) { feature in
42+
featureButton(feature)
43+
.padding(.bottom, 5)
44+
}
45+
}
46+
.padding(.top, UIScreen.main.bounds.width * 0.4 + 40)
47+
}
48+
.padding(.horizontal)
49+
3550
CachedAsyncImage(url: URL(string: config.logoUrl)) { phase in
3651
switch phase {
3752
case .empty:
@@ -46,10 +61,12 @@ struct EventView: View {
4661
}
4762
}
4863
.frame(width: UIScreen.main.bounds.width * 0.78, height: UIScreen.main.bounds.width * 0.4)
49-
50-
FeatureGrid(config: config)
64+
.frame(maxWidth: .infinity, alignment: .center)
65+
.padding(10)
66+
.background(BlurView(style: colorScheme == .dark ? .dark : .light))//
5167
}
5268
.onChange(of: eventID) { Task { await viewModel.loadEvent(reload: true) } }
69+
.toolbarBackground(.section, for: .navigationBar)
5370
.navigationBarTitleDisplayMode(.inline)
5471
.toolbar {
5572
ToolbarItem(placement: .principal) {
@@ -59,6 +76,39 @@ struct EventView: View {
5976
}
6077
}
6178

79+
@ViewBuilder
80+
private func featureButton(_ feature: Feature) -> some View {
81+
VStack {
82+
Button {
83+
84+
} label: {
85+
CachedAsyncImage(url: URL(string: feature.iconUrl ?? "")) { phase in
86+
switch phase {
87+
case .success(let image):
88+
image
89+
.renderingMode(.template)
90+
.interpolation(.none)
91+
.resizable()
92+
.scaledToFill()
93+
default:
94+
Image(systemName: feature.symbol)
95+
.resizable()
96+
.scaledToFill()
97+
.padding(3)
98+
}
99+
}
100+
}
101+
.buttonStyle(.bordered)
102+
.tint(feature.color)
103+
.frame(width: 50, height: 50)
104+
105+
Text(feature.label)
106+
.font(.custom("RobotoCondensed-Regular", size: 11, relativeTo: .caption2))
107+
.fixedSize(horizontal: false, vertical: true)
108+
.multilineTextAlignment(.center)
109+
}
110+
}
111+
62112
@ViewBuilder
63113
private func loadingView() -> some View {
64114
ProgressView("Loading")

0 commit comments

Comments
 (0)