Skip to content

Commit

Permalink
fix: build for iPadOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ggoraa committed Sep 26, 2022
1 parent 2bbc2b1 commit 0643663
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Moc.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
43C227D128CB097A00AE237C /* View+Faded.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C227D028CB097A00AE237C /* View+Faded.swift */; };
43C29C04287D8D9E00D10AB8 /* Animation+FastStartSlowStop.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C29C03287D8D9E00D10AB8 /* Animation+FastStartSlowStop.swift */; };
43EC18E22856782F00FCAD43 /* SearchField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EC18E12856782F00FCAD43 /* SearchField.swift */; platformFilter = ios; };
43F610FB28AFB8AE0098C3BD /* VisualEffectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F610FA28AFB8AE0098C3BD /* VisualEffectView.swift */; };
43F610FB28AFB8AE0098C3BD /* VisualEffectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F610FA28AFB8AE0098C3BD /* VisualEffectView.swift */; platformFilters = (macos, ); };
43F610FE28B01E830098C3BD /* MessageBubbleShape.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F610FD28B01E830098C3BD /* MessageBubbleShape.swift */; };
43F7C504287DCFB40083E9E9 /* ScrollOffsetPreferenceKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F7C503287DCFB40083E9E9 /* ScrollOffsetPreferenceKey.swift */; };
43F7D4CF28DA65FF00878BD8 /* Color+ContrastRatio.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F7D4CE28DA65FE00878BD8 /* Color+ContrastRatio.swift */; };
Expand Down
8 changes: 5 additions & 3 deletions Shared/Utils/Color+DynamicUserID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ extension Color {
@unknown default:
newLuminosity = 0.6
}

let nsColor = NSColor(self)
guard let coreColour = CIColor(color: nsColor) else { return self }
#if os(macOS)
guard let coreColour = CIColor(color: NSColor(self)) else { return self }
#elseif os(iOS)
let coreColour = CIColor(color: UIColor(self))
#endif
var red = coreColour.red
var green = coreColour.green
var blue = coreColour.blue
Expand Down
12 changes: 10 additions & 2 deletions Shared/Views/Common/FormattedTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ struct FormattedTextView: View {

switch entity.type {
case .bold:
if #available(macOS 13.0, *) {
if #available(macOS 13, iOS 16, *) {
resultString[range].font = .system(.body, weight: .bold)
} else {
resultString[range].font = .body.bold()
}
case .italic:
if #available(macOS 13.0, *) {
if #available(macOS 13, iOS 16, *) {
resultString[range].font = .system(.body).italic()
} else {
resultString[range].font = .body.italic()
Expand All @@ -54,17 +54,25 @@ struct FormattedTextView: View {
case .url:
resultString[range].link = URL(string: rawStringPart)
resultString[range].underlineStyle = .single
#if os(macOS)
resultString[range].cursor = .pointingHand
#endif
case let .textUrl(info):
resultString[range].link = URL(string: info.url)
resultString[range].underlineStyle = .single
#if os(macOS)
resultString[range].cursor = .pointingHand
#endif
case .phoneNumber:
resultString[range].link = URL(string: "tel:\(rawStringPart)")
#if os(macOS)
resultString[range].cursor = .pointingHand
#endif
case .emailAddress:
resultString[range].link = URL(string: "mailto:\(rawStringPart)")
#if os(macOS)
resultString[range].cursor = .pointingHand
#endif
default:
break
}
Expand Down
8 changes: 5 additions & 3 deletions Shared/Views/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct RootView: View {
openedChat = instance
}

private var chatList: some View {
private var chatListView: some View {
ScrollView {
LazyVStack {
ForEach(viewModel.chatList) { chat in
Expand Down Expand Up @@ -163,10 +163,12 @@ struct RootView: View {
}
}

#if os(macOS)
private func toggleSidebar() {
NSApp.keyWindow?.firstResponder?.tryToPerform(
#selector(NSSplitViewController.toggleSidebar(_:)), with: nil)
}
#endif

private func makeFolderItem(
name: String,
Expand Down Expand Up @@ -206,7 +208,7 @@ struct RootView: View {
}
.buttonStyle(.plain)
#if os(iOS)
.hoverEffect(viewModel.openChatList == chatList ? .lift : .highlight)
.hoverEffect(.lift)
#endif
}

Expand Down Expand Up @@ -305,7 +307,7 @@ struct RootView: View {
Group {
switch selectedTab {
case .chat:
chatList
chatListView
case .contacts:
Text("Contacts")
case .calls:
Expand Down
2 changes: 1 addition & 1 deletion Storage/Sources/Storage/StorageService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class StorageService {
} else {
dir = url.path
}
if #available(macOS 13.0, *) {
if #available(macOS 13, iOS 16, *) {
dir.replace("%20", with: " ")
} else {
dir = dir.replacingOccurrences(of: "%20", with: " ")
Expand Down

0 comments on commit 0643663

Please sign in to comment.