Skip to content

Commit

Permalink
iOS: Add Bulr effect
Browse files Browse the repository at this point in the history
  • Loading branch information
viere1234 committed Jan 5, 2025
1 parent a61269d commit 4bbbe70
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 6 deletions.
10 changes: 7 additions & 3 deletions iosApp/OPass.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

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

/* Begin PBXFileReference section */
D300355B2C85E31A0049B7B3 /* Shared+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Shared+Extension.swift"; sourceTree = "<group>"; };
D30235DA2CDC7AA80033D599 /* BlurView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlurView.swift; sourceTree = "<group>"; };
D307A8802C76039D00BB00FB /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
D307A8922C760F8E00BB00FB /* AppearanceSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppearanceSettingsView.swift; sourceTree = "<group>"; };
D34BEEC72C723BC6008F9A4C /* OPass.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OPass.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -178,7 +180,7 @@
D3EBBF652C8454D700A49285 /* Event */,
D39AC9DA2C7B394600084689 /* SelectEvent */,
D307A8912C760F5100BB00FB /* Settings */,
D3B1E77E2C774609002DBA07 /* General */,
D3B1E77E2C774609002DBA07 /* Common */,
D300355A2C85E3010049B7B3 /* Extension */,
);
path = OPass;
Expand Down Expand Up @@ -215,14 +217,15 @@
path = SelectEvent;
sourceTree = "<group>";
};
D3B1E77E2C774609002DBA07 /* General */ = {
D3B1E77E2C774609002DBA07 /* Common */ = {
isa = PBXGroup;
children = (
D30235DA2CDC7AA80033D599 /* BlurView.swift */,
D3B1E77F2C774623002DBA07 /* SafariView.swift */,
D3B1E7812C775E7C002DBA07 /* CenterLabelStyle.swift */,
D35A64EE2CDB00CD0085D41F /* CachedAsyncImage.swift */,
);
path = General;
path = Common;
sourceTree = "<group>";
};
D3C398062C73A190002FFD42 /* OneSignalNotificationServiceExtension */ = {
Expand Down Expand Up @@ -434,6 +437,7 @@
files = (
D35A64F12CDB04100085D41F /* FeatureGrid.swift in Sources */,
D3D1B8A02C7475A00075A747 /* SettingsView.swift in Sources */,
D30235DB2CDC7AA80033D599 /* BlurView.swift in Sources */,
D35A64EF2CDB00CD0085D41F /* CachedAsyncImage.swift in Sources */,
D34BEECD2C723BC6008F9A4C /* ContentView.swift in Sources */,
D3FA31322C8C457800949ECF /* GeneralSettingsView.swift in Sources */,
Expand Down
22 changes: 22 additions & 0 deletions iosApp/OPass/Common/BlurView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// BlurView.swift
// OPass
//
// Created by Brian Chang on 2024/11/7.
// 2024 OPass.
//

import SwiftUI


struct BlurView: UIViewRepresentable {
var style: UIBlurEffect.Style = .dark

func makeUIView(context: Context) -> UIVisualEffectView {
return UIVisualEffectView(effect: UIBlurEffect(style: style))
}

func updateUIView(_ uiView: UIVisualEffectView, context: Context) {
uiView.effect = UIBlurEffect(style: style)
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
56 changes: 53 additions & 3 deletions iosApp/OPass/Event/EventView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct EventView: View {
// MARK: - Variable
@State private var viewModel = EventViewModel()

@Environment(\.colorScheme) private var colorScheme
@AppStorage("EventID") private var eventID = ""

// MARK: - View
Expand All @@ -31,7 +32,21 @@ struct EventView: View {

@ViewBuilder
private func eventView(_ config: EventConfig) -> some View {
VStack {
ZStack(alignment: .top) {
ScrollView {
LazyVGrid(columns: .init(
repeating: .init(spacing: 30, alignment: .top),
count: 4
)) {
ForEach(config.features, id: \.self) { feature in
featureButton(feature)
.padding(.bottom, 5)
}
}
.padding(.top, UIScreen.main.bounds.width * 0.4 + 40)
}
.padding(.horizontal)

CachedAsyncImage(url: URL(string: config.logoUrl)) { phase in
switch phase {
case .empty:
Expand All @@ -46,10 +61,12 @@ struct EventView: View {
}
}
.frame(width: UIScreen.main.bounds.width * 0.78, height: UIScreen.main.bounds.width * 0.4)

FeatureGrid(config: config)
.frame(maxWidth: .infinity, alignment: .center)
.padding(10)
.background(BlurView(style: colorScheme == .dark ? .dark : .light))//
}
.onChange(of: eventID) { Task { await viewModel.loadEvent(reload: true) } }
.toolbarBackground(.section, for: .navigationBar)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .principal) {
Expand All @@ -59,6 +76,39 @@ struct EventView: View {
}
}

@ViewBuilder
private func featureButton(_ 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)
.frame(width: 50, height: 50)

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

@ViewBuilder
private func loadingView() -> some View {
ProgressView("Loading")
Expand Down

0 comments on commit 4bbbe70

Please sign in to comment.