Skip to content

Commit

Permalink
enhance: blur view effect (#4)
Browse files Browse the repository at this point in the history
enhance: blur view effect
  • Loading branch information
purr100 authored Nov 7, 2024
1 parent 2ba406c commit d04ebab
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ permissions: read-all

jobs:
build:
runs-on: macos-latest
runs-on: macos-15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Xcode
run: |
sudo xcode-select -s "/Applications/Xcode_16.app"
xcodebuild -version
# sudo xcode-select -s "/Applications/Xcode_16.app"
- name: Allow macro
run: |
defaults write com.apple.dt.Xcode IDESkipMacroFingerprintValidation -bool YES
Expand Down
30 changes: 28 additions & 2 deletions Chato.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
EB8FB4F32C3940D60041833B /* MarkdownUI in Frameworks */ = {isa = PBXBuildFile; productRef = EB8FB4F22C3940D60041833B /* MarkdownUI */; };
EB9E72012BCAB5FB00D5B110 /* Product.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB9E72002BCAB5FB00D5B110 /* Product.swift */; };
EB9E72042BCAB7DF00D5B110 /* ConfettiSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = EB9E72032BCAB7DF00D5B110 /* ConfettiSwiftUI */; };
EBA73E2F2CDD3006007E480C /* VisualEffectView in Frameworks */ = {isa = PBXBuildFile; productRef = EBA73E2E2CDD3006007E480C /* VisualEffectView */; };
EBA73E322CDD3405007E480C /* VisualEffectView in Frameworks */ = {isa = PBXBuildFile; productRef = EBA73E312CDD3405007E480C /* VisualEffectView */; };
EBA75D8C2C380C24003FC64D /* Ripple.metal in Sources */ = {isa = PBXBuildFile; fileRef = EBA75D8B2C380C24003FC64D /* Ripple.metal */; };
EBB075C52B938AB8007328EF /* PromptSample.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBB075C42B938AB8007328EF /* PromptSample.swift */; };
EBB075C82B93949A007328EF /* PromptListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBB075C72B93949A007328EF /* PromptListView.swift */; };
Expand Down Expand Up @@ -165,6 +167,7 @@
EB8DFFA02B98E87A00862A94 /* PromptCreateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromptCreateView.swift; sourceTree = "<group>"; };
EB9E72002BCAB5FB00D5B110 /* Product.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Product.swift; sourceTree = "<group>"; };
EBA256B02BCAD15000141F3E /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
EBA73E2C2CDD2FD2007E480C /* VisualEffectView */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = VisualEffectView; path = ../../../Downloads/VisualEffectView; sourceTree = "<group>"; };
EBA75D8B2C380C24003FC64D /* Ripple.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = Ripple.metal; sourceTree = "<group>"; };
EBB075C42B938AB8007328EF /* PromptSample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromptSample.swift; sourceTree = "<group>"; };
EBB075C72B93949A007328EF /* PromptListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromptListView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -193,7 +196,9 @@
files = (
EBCFF3952B6FF4CC00498E1E /* Throttler in Frameworks */,
EB4A0EE52B6F908D0065BCDC /* OpenAI in Frameworks */,
EBA73E2F2CDD3006007E480C /* VisualEffectView in Frameworks */,
EBC857802C39599800DE2252 /* Splash in Frameworks */,
EBA73E322CDD3405007E480C /* VisualEffectView in Frameworks */,
EB8FB4F32C3940D60041833B /* MarkdownUI in Frameworks */,
EBD0114C2B98F2840046F235 /* Haptico in Frameworks */,
EB9E72042BCAB7DF00D5B110 /* ConfettiSwiftUI in Frameworks */,
Expand Down Expand Up @@ -259,6 +264,7 @@
EB4A0EE32B6F908D0065BCDC /* Frameworks */ = {
isa = PBXGroup;
children = (
EBA73E2C2CDD2FD2007E480C /* VisualEffectView */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -530,6 +536,8 @@
EB9E72032BCAB7DF00D5B110 /* ConfettiSwiftUI */,
EB8FB4F22C3940D60041833B /* MarkdownUI */,
EBC8577F2C39599800DE2252 /* Splash */,
EBA73E2E2CDD3006007E480C /* VisualEffectView */,
EBA73E312CDD3405007E480C /* VisualEffectView */,
);
productName = Chato;
productReference = EB6422102B6F7BB000119DE6 /* Chato.app */;
Expand Down Expand Up @@ -567,6 +575,7 @@
EB9E72022BCAB7DF00D5B110 /* XCRemoteSwiftPackageReference "ConfettiSwiftUI" */,
EB8FB4F12C3940D60041833B /* XCRemoteSwiftPackageReference "swift-markdown-ui" */,
EBC8577E2C39599800DE2252 /* XCRemoteSwiftPackageReference "Splash" */,
EBA73E302CDD3405007E480C /* XCRemoteSwiftPackageReference "VisualEffectView" */,
);
productRefGroup = EB6422112B6F7BB000119DE6 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -819,7 +828,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 18.0.2;
MARKETING_VERSION = 18.0.3;
PRODUCT_BUNDLE_IDENTIFIER = app.moderato.Chato.Chato.debug;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -861,7 +870,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 18.0.2;
MARKETING_VERSION = 18.0.3;
PRODUCT_BUNDLE_IDENTIFIER = app.moderato.Chato.Chato;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -922,6 +931,14 @@
kind = branch;
};
};
EBA73E302CDD3405007E480C /* XCRemoteSwiftPackageReference "VisualEffectView" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/efremidze/VisualEffectView";
requirement = {
branch = master;
kind = branch;
};
};
EBC8577E2C39599800DE2252 /* XCRemoteSwiftPackageReference "Splash" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/JohnSundell/Splash.git";
Expand Down Expand Up @@ -964,6 +981,15 @@
package = EB9E72022BCAB7DF00D5B110 /* XCRemoteSwiftPackageReference "ConfettiSwiftUI" */;
productName = ConfettiSwiftUI;
};
EBA73E2E2CDD3006007E480C /* VisualEffectView */ = {
isa = XCSwiftPackageProductDependency;
productName = VisualEffectView;
};
EBA73E312CDD3405007E480C /* VisualEffectView */ = {
isa = XCSwiftPackageProductDependency;
package = EBA73E302CDD3405007E480C /* XCRemoteSwiftPackageReference "VisualEffectView" */;
productName = VisualEffectView;
};
EBC8577F2C39599800DE2252 /* Splash */ = {
isa = XCSwiftPackageProductDependency;
package = EBC8577E2C39599800DE2252 /* XCRemoteSwiftPackageReference "Splash" */;
Expand Down
1 change: 0 additions & 1 deletion Chato/Models/Data/ChatGPT.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ let chatGPTModels = [
defaultGPTModel,
ChatGPTModel("GPT4", "gpt-4", 4),
ChatGPTModel("GPT-4o", "gpt-4o", 4),
ChatGPTModel("GPT-4o 2024-08-06", "gpt-4o-2024-08-06", 4),
ChatGPTModel("o1-preview", "o1-preview", 4),
ChatGPTModel("o1-mini", "o1-mini", 4),
ChatGPTModel("GPT-4 Turbo", "gpt-4-turbo", 4),
Expand Down
32 changes: 0 additions & 32 deletions Chato/Theme+Effect/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ public extension View {
func lovelyRow() -> some View {
modifier(LoveRowView())
}

func lovelyNavi() -> some View {
modifier(LovelyNaviModifier())
}
}

struct LoveRowView: ViewModifier {
Expand Down Expand Up @@ -127,34 +123,6 @@ struct NavAppearanceModifier: ViewModifier {
}
}

struct LovelyNaviModifier: ViewModifier {
init() {
let navBarAppearance = UINavigationBarAppearance()
navBarAppearance.backgroundEffect = UIBlurEffect(style: .systemUltraThinMaterial)
navBarAppearance.shadowColor = .clear
UINavigationBar.appearance().standardAppearance = navBarAppearance
// UINavigationBar.appearance().compactAppearance = navBarAppearance
// UINavigationBar.appearance().scrollEdgeAppearance = navBarAppearance
}

func body(content: Content) -> some View {
content
}
}

struct VisualEffectView: UIViewRepresentable {
var isDark: Bool

func makeUIView(context: UIViewRepresentableContext<Self>) -> UIVisualEffectView { UIVisualEffectView() }
func updateUIView(_ uiView: UIVisualEffectView, context: UIViewRepresentableContext<Self>) {
if isDark {
uiView.effect = UIBlurEffect(style: .systemUltraThinMaterialDark)
} else {
uiView.effect = UIBlurEffect(style: .light)
}
}
}

#Preview {
LovelyPreview {
HomePage()
Expand Down
1 change: 0 additions & 1 deletion Chato/Views/HomePage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ struct HomePage: View {
}
}
}
.lovelyNavi()
.navigationDestination(for: Chat.self) { chat in
ChatDetailView(chat: chat)
}
Expand Down
12 changes: 9 additions & 3 deletions Chato/Views/MessageList/MessageList.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import SwiftData
import SwiftUI
import VisualEffectView

struct MessageList: View {
@EnvironmentObject var em: EM
Expand Down Expand Up @@ -77,7 +78,7 @@ struct MessageList: View {
.scrollDismissesKeyboard(.interactively)
.removeFocusOnTap()
.safeAreaInset(edge: .top, spacing: 0) {
VisualEffectView(isDark: colorScheme == .dark)
VisualEffect(colorTint: visualTint, colorTintAlpha: 0.5, blurRadius: 18, scale: 1)
.ignoresSafeArea(edges: .top)
.frame(height: 0)
}
Expand All @@ -90,8 +91,9 @@ struct MessageList: View {
}
.safeAreaInset(edge: .bottom, spacing: 0) {
InputAreaView(chat: chat, newChatCallback: onMsgCountChange)
.background(VisualEffectView(isDark: colorScheme == .dark)
.ignoresSafeArea(edges: .bottom))
.background(
VisualEffect(colorTint: visualTint, colorTintAlpha: 0.5, blurRadius: 18, scale: 1)
.ignoresSafeArea(edges: .bottom))
.overlay(alignment: .topTrailing) {
HStack {
if !lastMsgOnScreen {
Expand Down Expand Up @@ -134,6 +136,10 @@ struct MessageList: View {
}
}
}

var visualTint: Color {
colorScheme == .dark ? .black : .white
}
}

#Preview {
Expand Down

0 comments on commit d04ebab

Please sign in to comment.