From adb32a3d3d10c0cd80206e48a2cc348966d90933 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Mon, 22 Jan 2024 18:15:22 -0300 Subject: [PATCH] Deployment Target WatchOS 8 --- ios/RocketChat Watch App/AppView.swift | 2 +- .../Client/Adapters/TokenAdapter.swift | 6 +--- .../Client/Extensions/URL+Extensions.swift | 15 ++++++++ .../Database/RocketChatDatabase.swift | 1 + .../Views/RoomListView.swift | 23 ++++++------ .../Views/ViewModifier.swift | 35 +++++++++++++++++++ ios/RocketChatRN.xcodeproj/project.pbxproj | 12 +++++-- 7 files changed, 74 insertions(+), 20 deletions(-) create mode 100644 ios/RocketChat Watch App/Client/Extensions/URL+Extensions.swift create mode 100644 ios/RocketChat Watch App/Views/ViewModifier.swift diff --git a/ios/RocketChat Watch App/AppView.swift b/ios/RocketChat Watch App/AppView.swift index c17827eac..bbb76a361 100644 --- a/ios/RocketChat Watch App/AppView.swift +++ b/ios/RocketChat Watch App/AppView.swift @@ -12,7 +12,7 @@ struct AppView: View { } var body: some View { - NavigationStack { + NavigationView { switch router.route { case .loading: ProgressView() diff --git a/ios/RocketChat Watch App/Client/Adapters/TokenAdapter.swift b/ios/RocketChat Watch App/Client/Adapters/TokenAdapter.swift index e64c95441..e96839766 100644 --- a/ios/RocketChat Watch App/Client/Adapters/TokenAdapter.swift +++ b/ios/RocketChat Watch App/Client/Adapters/TokenAdapter.swift @@ -8,16 +8,12 @@ struct TokenAdapter: RequestAdapter { } func adapt(_ url: URL) -> URL { - var url = url - - url.append( + url.appending( queryItems: [ URLQueryItem(name: "rc_token", value: server.loggedUser.token), URLQueryItem(name: "rc_uid", value: server.loggedUser.id) ] ) - - return url } func adapt(_ urlRequest: URLRequest) -> URLRequest { diff --git a/ios/RocketChat Watch App/Client/Extensions/URL+Extensions.swift b/ios/RocketChat Watch App/Client/Extensions/URL+Extensions.swift new file mode 100644 index 000000000..1a4663487 --- /dev/null +++ b/ios/RocketChat Watch App/Client/Extensions/URL+Extensions.swift @@ -0,0 +1,15 @@ +import Foundation + +extension URL { + func appending(queryItems: [URLQueryItem]) -> Self { + var components = URLComponents(url: self, resolvingAgainstBaseURL: true) + + components?.queryItems = queryItems + + return components?.url ?? self + } + + func appending(path: String) -> Self { + appendingPathComponent(path) + } +} diff --git a/ios/RocketChat Watch App/Database/RocketChatDatabase.swift b/ios/RocketChat Watch App/Database/RocketChatDatabase.swift index 5f47dfbba..dda326381 100644 --- a/ios/RocketChat Watch App/Database/RocketChatDatabase.swift +++ b/ios/RocketChat Watch App/Database/RocketChatDatabase.swift @@ -92,6 +92,7 @@ final class RocketChatDatabase: Database { message.room = room message.status = "temp" // TODO: message.msg = msg + message.groupable = true let user = user(id: loggedUser.id) ?? createUser(id: loggedUser.id) user.username = loggedUser.username diff --git a/ios/RocketChat Watch App/Views/RoomListView.swift b/ios/RocketChat Watch App/Views/RoomListView.swift index 33f740d99..f3d733d37 100644 --- a/ios/RocketChat Watch App/Views/RoomListView.swift +++ b/ios/RocketChat Watch App/Views/RoomListView.swift @@ -20,7 +20,17 @@ struct RoomListView: View { var body: some View { List { ForEach(rooms) { room in - NavigationLink(value: room) { + NavigationLink { + MessageListView( + client: client, + database: database, + messagesLoader: messagesLoader, + messageSender: messageSender, + room: room, + server: server + ) + .environment(\.managedObjectContext, database.viewContext) + } label: { RoomView(viewModel: .init(room: room, server: server)) } } @@ -33,17 +43,6 @@ struct RoomListView: View { } .navigationTitle("Rooms") .navigationBarTitleDisplayMode(.inline) - .navigationDestination(for: Room.self) { room in - MessageListView( - client: client, - database: database, - messagesLoader: messagesLoader, - messageSender: messageSender, - room: room, - server: server - ) - .environment(\.managedObjectContext, database.viewContext) - } .toolbar { ToolbarItem(placement: .automatic) { Button("Servers") { diff --git a/ios/RocketChat Watch App/Views/ViewModifier.swift b/ios/RocketChat Watch App/Views/ViewModifier.swift new file mode 100644 index 000000000..c222856d8 --- /dev/null +++ b/ios/RocketChat Watch App/Views/ViewModifier.swift @@ -0,0 +1,35 @@ +import SwiftUI + +struct FontWeightModifier: ViewModifier { + @Environment(\.font) var font + + private let weight: Font.Weight + + init(_ weight: Font.Weight) { + self.weight = weight + } + + func body(content: Content) -> some View { + content + .font(font?.weight(weight)) + } +} + +struct ItalicModifier: ViewModifier { + @Environment(\.font) var font + + func body(content: Content) -> some View { + content + .font(font?.italic()) + } +} + +extension View { + func fontWeight(_ weight: Font.Weight) -> some View { + modifier(FontWeightModifier(weight)) + } + + func italic() -> some View { + modifier(ItalicModifier()) + } +} diff --git a/ios/RocketChatRN.xcodeproj/project.pbxproj b/ios/RocketChatRN.xcodeproj/project.pbxproj index ace1ac7a3..e355659fc 100644 --- a/ios/RocketChatRN.xcodeproj/project.pbxproj +++ b/ios/RocketChatRN.xcodeproj/project.pbxproj @@ -88,6 +88,8 @@ 1E598AE725150660002BDFBD /* Data+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E598AE625150660002BDFBD /* Data+Extensions.swift */; }; 1E598AE925151A63002BDFBD /* SendMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E598AE825151A63002BDFBD /* SendMessage.swift */; }; 1E638E992B5F0A2900E645E4 /* ChatScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E638E982B5F0A2900E645E4 /* ChatScrollView.swift */; }; + 1E638E9C2B5F0CFD00E645E4 /* ViewModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E638E9B2B5F0CFD00E645E4 /* ViewModifier.swift */; }; + 1E638E9E2B5F0F5800E645E4 /* URL+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E638E9D2B5F0F5800E645E4 /* URL+Extensions.swift */; }; 1E67380424DC529B0009E081 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E67380324DC529B0009E081 /* String+Extensions.swift */; }; 1E680ED92512990700C9257A /* Request.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E680ED82512990700C9257A /* Request.swift */; }; 1E6CC61F2513DBF400965591 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7A006F13229C83B600803143 /* GoogleService-Info.plist */; }; @@ -401,6 +403,8 @@ 1E598AE625150660002BDFBD /* Data+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+Extensions.swift"; sourceTree = ""; }; 1E598AE825151A63002BDFBD /* SendMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendMessage.swift; sourceTree = ""; }; 1E638E982B5F0A2900E645E4 /* ChatScrollView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatScrollView.swift; sourceTree = ""; }; + 1E638E9B2B5F0CFD00E645E4 /* ViewModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewModifier.swift; sourceTree = ""; }; + 1E638E9D2B5F0F5800E645E4 /* URL+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+Extensions.swift"; sourceTree = ""; }; 1E6737FF24DC52660009E081 /* NotificationService-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NotificationService-Bridging-Header.h"; sourceTree = ""; }; 1E67380324DC529B0009E081 /* String+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extensions.swift"; sourceTree = ""; }; 1E680ED82512990700C9257A /* Request.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Request.swift; sourceTree = ""; }; @@ -662,6 +666,7 @@ 1E29A3092B585B370093C03C /* Data+Extensions.swift */, 1E29A30B2B585D1D0093C03C /* String+Extensions.swift */, 1E4AFC1A2B5AFC6A00E2AA7D /* Publisher+Extensions.swift */, + 1E638E9D2B5F0F5800E645E4 /* URL+Extensions.swift */, ); path = Extensions; sourceTree = ""; @@ -795,6 +800,7 @@ 1E4AFC262B5B23C600E2AA7D /* RetryView.swift */, 1EDB30F12B5B453A00532C7E /* LoggedInView.swift */, 1E638E982B5F0A2900E645E4 /* ChatScrollView.swift */, + 1E638E9B2B5F0CFD00E645E4 /* ViewModifier.swift */, ); path = Views; sourceTree = ""; @@ -1893,6 +1899,7 @@ 1E29A2FB2B585B070093C03C /* MessagesRequest.swift in Sources */, 1E29A31D2B5871B60093C03C /* Date+Extensions.swift in Sources */, 1E29A2F62B585B070093C03C /* UserResponse.swift in Sources */, + 1E638E9C2B5F0CFD00E645E4 /* ViewModifier.swift in Sources */, 1ED033AE2B55B1CC004F4930 /* Default.xcdatamodeld in Sources */, 1ED033BF2B55BF94004F4930 /* Storage.swift in Sources */, 1E29A2F82B585B070093C03C /* MessageResponse.swift in Sources */, @@ -1904,6 +1911,7 @@ 1E29A2FA2B585B070093C03C /* HistoryRequest.swift in Sources */, 1ED038C62B50A21800C007D4 /* WatchMessage.swift in Sources */, 1E29A2F02B585B070093C03C /* AttachmentResponse.swift in Sources */, + 1E638E9E2B5F0F5800E645E4 /* URL+Extensions.swift in Sources */, 1ED038912B507B4C00C007D4 /* RocketChatApp.swift in Sources */, 1E29A2CC2B5857F50093C03C /* RoomListView.swift in Sources */, 1E29A31A2B5868EE0093C03C /* MessageViewModel.swift in Sources */, @@ -2328,7 +2336,7 @@ SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 9.0; + WATCHOS_DEPLOYMENT_TARGET = 8.0; }; name = Debug; }; @@ -2370,7 +2378,7 @@ SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 9.0; + WATCHOS_DEPLOYMENT_TARGET = 8.0; }; name = Release; };