Skip to content

Commit

Permalink
fix(ui): sidebar blur fix with NSEffectView
Browse files Browse the repository at this point in the history
fix(dm)!: load DMs when selected - relies on change in DiscordKit

patch(ui): toolbar visual fixes
  • Loading branch information
cryptoAlgorithm committed Sep 24, 2023
1 parent 2fac042 commit af08ae4
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 99 deletions.
6 changes: 6 additions & 0 deletions Swiftcord.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
9FCE7B1D28C7140100213A3F /* ServerFolder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCE7B1C28C7140100213A3F /* ServerFolder.swift */; };
9FCE7B1E28C7140100213A3F /* ServerFolder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCE7B1C28C7140100213A3F /* ServerFolder.swift */; };
DA03DA3F284F1E9200257790 /* Keychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA03DA3E284F1E9200257790 /* Keychain.swift */; };
DA120C5D2ABF172600C9E7CE /* VisualEffect.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA120C5C2ABF172600C9E7CE /* VisualEffect.swift */; };
DA120C5E2ABF172600C9E7CE /* VisualEffect.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA120C5C2ABF172600C9E7CE /* VisualEffect.swift */; };
DA12FB7C29AB84F500EDBBEE /* Lottie in Frameworks */ = {isa = PBXBuildFile; productRef = DA12FB7B29AB84F500EDBBEE /* Lottie */; };
DA2384A127CB9714009E15E0 /* Font+.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2384A027CB9714009E15E0 /* Font+.swift */; };
DA2384BA27CBC2CE009E15E0 /* GintoBold.otf in Resources */ = {isa = PBXBuildFile; fileRef = DA2384B827CBC2CE009E15E0 /* GintoBold.otf */; };
Expand Down Expand Up @@ -285,6 +287,7 @@
DA03DA3E284F1E9200257790 /* Keychain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Keychain.swift; sourceTree = "<group>"; };
DA0FC06929AC385B00ADB012 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = "<group>"; };
DA0FC06A29AC4B6900ADB012 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/Localizable.strings; sourceTree = "<group>"; };
DA120C5C2ABF172600C9E7CE /* VisualEffect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VisualEffect.swift; sourceTree = "<group>"; };
DA23843827CB934D009E15E0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
DA2384A027CB9714009E15E0 /* Font+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Font+.swift"; sourceTree = "<group>"; };
DA2384B827CBC2CE009E15E0 /* GintoBold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = GintoBold.otf; sourceTree = "<group>"; };
Expand Down Expand Up @@ -752,6 +755,7 @@
DAAFB5BB282A570D00807B54 /* CircularProgressView.swift */,
DA4350032879C38C001DEC81 /* HorizontalDividerView.swift */,
DAB1E46B28A10BB100645FCD /* BetterImageView.swift */,
DA120C5C2ABF172600C9E7CE /* VisualEffect.swift */,
);
path = Utils;
sourceTree = "<group>";
Expand Down Expand Up @@ -1086,6 +1090,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DA120C5E2ABF172600C9E7CE /* VisualEffect.swift in Sources */,
9FCE7B1E28C7140100213A3F /* ServerFolder.swift in Sources */,
DA91017728C3989E00DD076B /* AccountMeta.swift in Sources */,
DAB1E48828A50D3600645FCD /* DefaultMessageView.swift in Sources */,
Expand Down Expand Up @@ -1303,6 +1308,7 @@
DA91017628C3989E00DD076B /* AccountMeta.swift in Sources */,
DABD8BB72882E9E0008EE28F /* DateFormatter+.swift in Sources */,
DA32EF3227C676FE00A9ED72 /* LottieLoopMode.swift in Sources */,
DA120C5D2ABF172600C9E7CE /* VisualEffect.swift in Sources */,
DAFD4710289A1FEB0075D71B /* AttachmentAudio.swift in Sources */,
DA28027F28095E3100B14E5C /* Logger+.swift in Sources */,
DA54D574284497E400B11857 /* ProfileAccentMask.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"location" : "https://github.com/microsoft/appcenter-sdk-apple",
"state" : {
"branch" : "develop",
"revision" : "2214f9ee2476f28af64cb38359defe59e85197a1"
"revision" : "0156f967b87b6a67104318baa665776b35be0830"
}
},
{
Expand All @@ -24,16 +24,16 @@
"location" : "https://github.com/SwiftcordApp/DiscordKit",
"state" : {
"branch" : "main",
"revision" : "1474f71dabb18050cc2422d08643731b7aecf6a4"
"revision" : "efd8cd571d85821bc5d622fa50961042c084776a"
}
},
{
"identity" : "lottie-spm",
"kind" : "remoteSourceControl",
"location" : "https://github.com/airbnb/lottie-spm.git",
"state" : {
"revision" : "c3852816c622ad35a03ed39c187c1644ece2382b",
"version" : "4.1.3"
"revision" : "3094834a82a75dae679fbe593f08bf1b168c2afe",
"version" : "4.3.1"
}
},
{
Expand All @@ -50,8 +50,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/microsoft/PLCrashReporter.git",
"state" : {
"revision" : "b1a342da19ed9b3af61ea2efa7656c2af30aeb7c",
"version" : "1.11.0"
"revision" : "1aed8f7dc79ce8e674c61e430ef51ca3db18cea9",
"version" : "1.11.1"
}
},
{
Expand All @@ -77,8 +77,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/sparkle-project/Sparkle",
"state" : {
"revision" : "dda155c7d3ef38c53d29f8584cb2aad2a1a54dba",
"version" : "2.3.2"
"revision" : "f0ceaf5cc9f3f23daa0ccb6dcebd79fc96ccc7d9",
"version" : "2.5.0"
}
},
{
Expand All @@ -95,8 +95,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "32e8d724467f8fe623624570367e3d50c5638e46",
"version" : "1.5.2"
"revision" : "532d8b529501fb73a2455b179e0bbb6d49b652ed",
"version" : "1.5.3"
}
},
{
Expand All @@ -122,8 +122,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "f25867a208f459d3c5a06935dceb9083b11cd539",
"version" : "1.22.0"
"revision" : "cf62cdaea48b77f1a631e5cb3aeda6047c2cba1d",
"version" : "1.23.0"
}
},
{
Expand All @@ -132,16 +132,16 @@
"location" : "https://github.com/lorenzofiamingo/swiftui-cached-async-image",
"state" : {
"branch" : "main",
"revision" : "f94be38411297c71aa8df69c6875127e6d8d7a92"
"revision" : "2abb11839f80ebb07a58ac5e146a1da664260c16"
}
},
{
"identity" : "swiftui-introspect",
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/SwiftUI-Introspect.git",
"state" : {
"revision" : "c18951c747ab62af7c15e17a81bd37d4fd5a9979",
"version" : "0.2.3"
"revision" : "121c146fe591b1320238d054ae35c81ffa45f45a",
"version" : "0.12.0"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>Swiftcord (App Store).xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
<integer>1</integer>
</dict>
<key>Swiftcord.xcscheme_^#shared#^_</key>
<dict>
Expand Down
63 changes: 29 additions & 34 deletions Swiftcord/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,26 @@ struct ContentView: View {

private let log = Logger(category: "ContentView")

private func makeDMGuild() -> Guild {
Guild(
id: "@me",
name: "DMs",
owner_id: "",
afk_timeout: 0,
verification_level: .none,
default_message_notifications: .all,
explicit_content_filter: .disabled,
roles: [], emojis: [], features: [],
mfa_level: .none,
system_channel_flags: 0,
private func makeDMGuild() -> PreloadedGuild {
PreloadedGuild(
channels: gateway.cache.dms,
premium_tier: .none,
preferred_locale: .englishUS,
nsfw_level: .default,
premium_progress_bar_enabled: false
properties: Guild(
id: "@me",
name: "DMs",
owner_id: "",
afk_timeout: 0,
verification_level: .none,
default_message_notifications: .all,
explicit_content_filter: .disabled,
roles: [], emojis: [], features: [],
mfa_level: .none,
system_channel_flags: 0,
channels: gateway.cache.dms,
premium_tier: .none,
preferred_locale: .englishUS,
nsfw_level: .default,
premium_progress_bar_enabled: false
)
)
}

Expand Down Expand Up @@ -96,7 +99,8 @@ struct ContentView: View {
assetIconName: "DiscordIcon"
) {
state.selectedGuildID = "@me"
}.padding(.top, 4)
}
.padding(.top, 4)

HorizontalDividerView().frame(width: 32)

Expand All @@ -107,9 +111,10 @@ struct ContentView: View {
selected: state.selectedGuildID == guild.id || loadingGuildID == guild.id,
name: guild.properties.name,
serverIconURL: guild.properties.icon != nil ? "\(DiscordKitConfig.default.cdnURL)icons/\(guild.id)/\(guild.properties.icon!).webp?size=240" : nil,
isLoading: loadingGuildID == guild.id,
onSelect: { state.selectedGuildID = guild.id }
)
isLoading: loadingGuildID == guild.id
) {
state.selectedGuildID = guild.id
}
case .guildFolder(let folder):
ServerFolder(
folder: folder,
Expand All @@ -132,27 +137,17 @@ struct ContentView: View {
.padding(.bottom, 8)
.frame(width: 72)
}
.background(
List {}
.listStyle(.sidebar)
.overlay(Color(nsColor: NSColor.controlBackgroundColor).opacity(0.5))
)
.frame(maxHeight: .infinity, alignment: .top)
.background(VisualEffect()
.overlay(Color(nsColor: NSColor.controlBackgroundColor).opacity(0.5))
)

ServerView(
guild: state.selectedGuildID == nil
? nil
: ( gateway.cache.guilds[state.selectedGuildID!]), serverCtx: state.serverCtx
: (state.selectedGuildID == "@me" ? makeDMGuild() : gateway.cache.guilds[state.selectedGuildID!]), serverCtx: state.serverCtx
)
}
// Blur the area behind the toolbar so the content doesn't show thru
.safeAreaInset(edge: .top) {
VStack {
Divider().frame(maxWidth: .infinity)
}
.frame(maxWidth: .infinity)
.background(.ultraThinMaterial)
}
.environmentObject(audioManager)
.onChange(of: state.selectedGuildID) { id in
guard let id = id else { return }
Expand Down
8 changes: 8 additions & 0 deletions Swiftcord/Views/Message/MessagesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ struct MessagesView: View {
historyList
inputContainer
}
// Blur the area behind the toolbar so the content doesn't show thru
.safeAreaInset(edge: .top) {
VStack {
Divider().frame(maxWidth: .infinity)
}
.frame(maxWidth: .infinity)
.background(.ultraThinMaterial)
}
.frame(minWidth: 525, minHeight: 500)
// .blur(radius: viewModel.dropOver ? 8 : 0)
.overlay {
Expand Down
2 changes: 1 addition & 1 deletion Swiftcord/Views/Server/ChannelList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct ChannelList: View, Equatable {
.contains(.viewChannel)
}
List {
Spacer(minLength: 52 - 16 + 4) // 52 (header) - 16 (unremovable section top padding) + 4 (spacing)
// Spacer(minLength: 4).listRowInsets(.init(top: 0, leading: 0, bottom: 0, trailing: 0)) // 38 (header) - 16 (unremovable section top padding) + 4 (spacing)

let filteredChannels = availableChs.filter {
$0.parent_id == nil && $0.type != .category && (nsfwShown || ($0.nsfw == false || $0.nsfw == nil))
Expand Down

0 comments on commit af08ae4

Please sign in to comment.