From 7281d84d9fb47167f260677bebb0fa9dc6e6ba54 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Tue, 23 Jan 2024 16:37:35 -0300 Subject: [PATCH] Fix WatchOS 8 compatibility --- .../Extensions/Publisher+Extensions.swift | 28 --------------- .../Loaders/ServersLoader.swift | 1 - .../Views/MessageComposerView.swift | 3 +- .../Views/MessageView.swift | 6 ++-- ios/RocketChat Watch App/Views/RoomView.swift | 9 ++--- .../Views/ServerView.swift | 3 +- .../Views/ViewModifier.swift | 35 ------------------- ios/RocketChatRN.xcodeproj/project.pbxproj | 8 ----- 8 files changed, 7 insertions(+), 86 deletions(-) delete mode 100644 ios/RocketChat Watch App/Client/Extensions/Publisher+Extensions.swift delete mode 100644 ios/RocketChat Watch App/Views/ViewModifier.swift diff --git a/ios/RocketChat Watch App/Client/Extensions/Publisher+Extensions.swift b/ios/RocketChat Watch App/Client/Extensions/Publisher+Extensions.swift deleted file mode 100644 index 675225b18..000000000 --- a/ios/RocketChat Watch App/Client/Extensions/Publisher+Extensions.swift +++ /dev/null @@ -1,28 +0,0 @@ -import Combine - -extension Publisher { - func retryWithDelay( - retries: Int, - delay: S.SchedulerTimeType.Stride, - scheduler: S - ) -> AnyPublisher where S: Scheduler { - self - .delayIfFailure(for: delay, scheduler: scheduler) - .retry(retries) - .eraseToAnyPublisher() - } - - private func delayIfFailure( - for delay: S.SchedulerTimeType.Stride, - scheduler: S - ) -> AnyPublisher where S: Scheduler { - self.catch { error in - Future { completion in - scheduler.schedule(after: scheduler.now.advanced(by: delay)) { - completion(.failure(error)) - } - } - } - .eraseToAnyPublisher() - } -} diff --git a/ios/RocketChat Watch App/Loaders/ServersLoader.swift b/ios/RocketChat Watch App/Loaders/ServersLoader.swift index a0e2df818..ea2521ac0 100644 --- a/ios/RocketChat Watch App/Loaders/ServersLoader.swift +++ b/ios/RocketChat Watch App/Loaders/ServersLoader.swift @@ -91,7 +91,6 @@ extension ServersLoader: ServersLoading { } } } - .retryWithDelay(retries: 3, delay: 1, scheduler: DispatchQueue.global()) .eraseToAnyPublisher() } } diff --git a/ios/RocketChat Watch App/Views/MessageComposerView.swift b/ios/RocketChat Watch App/Views/MessageComposerView.swift index e67c1fbc7..f57aeeb02 100644 --- a/ios/RocketChat Watch App/Views/MessageComposerView.swift +++ b/ios/RocketChat Watch App/Views/MessageComposerView.swift @@ -11,8 +11,7 @@ struct MessageComposerView: View { HStack { Spacer() Text("This room is read only") - .font(.caption) - .fontWeight(.bold) + .font(.caption.bold()) .foregroundStyle(.white) .multilineTextAlignment(.center) Spacer() diff --git a/ios/RocketChat Watch App/Views/MessageView.swift b/ios/RocketChat Watch App/Views/MessageView.swift index 45df6b36e..a6420ffec 100644 --- a/ios/RocketChat Watch App/Views/MessageView.swift +++ b/ios/RocketChat Watch App/Views/MessageView.swift @@ -55,8 +55,7 @@ struct MessageView: View { HStack(alignment: .center) { Text(viewModel.sender ?? "") .lineLimit(1) - .font(.caption) - .fontWeight(.bold) + .font(.caption.bold()) .foregroundStyle(.primary) Text(viewModel.messageFormatter.time() ?? "") .lineLimit(1) @@ -66,9 +65,8 @@ struct MessageView: View { } if let text = viewModel.messageFormatter.info() { Text(text) - .font(.caption) + .font(.caption.italic()) .foregroundStyle(.primary) - .italic() } else if let text = viewModel.message.msg { Text(text) .font(.caption) diff --git a/ios/RocketChat Watch App/Views/RoomView.swift b/ios/RocketChat Watch App/Views/RoomView.swift index 54395d24d..2a023794e 100644 --- a/ios/RocketChat Watch App/Views/RoomView.swift +++ b/ios/RocketChat Watch App/Views/RoomView.swift @@ -18,14 +18,12 @@ struct RoomView: View { } Text(viewModel.formatter.title ?? "") .lineLimit(1) - .font(.caption) - .fontWeight(isUnread ? .bold : .medium) + .font(.caption.weight(isUnread ? .bold : .medium)) .foregroundStyle(.primary) Spacer() Text(viewModel.updatedAt ?? "") .lineLimit(1) - .font(.footnote) - .fontWeight(isUnread ? .bold : .medium) + .font(.footnote.weight(isUnread ? .bold : .medium)) .foregroundStyle(isUnread ? .blue : .primary) } HStack(alignment: .top) { @@ -36,8 +34,7 @@ struct RoomView: View { Spacer() if isUnread, viewModel.room.unread > 0 { Text(String(viewModel.room.unread)) - .font(.footnote) - .fontWeight(.bold) + .font(.footnote.bold()) .padding(6) .background( Circle() diff --git a/ios/RocketChat Watch App/Views/ServerView.swift b/ios/RocketChat Watch App/Views/ServerView.swift index ea86d33fc..8100cbb24 100644 --- a/ios/RocketChat Watch App/Views/ServerView.swift +++ b/ios/RocketChat Watch App/Views/ServerView.swift @@ -6,8 +6,7 @@ struct ServerView: View { var body: some View { VStack(alignment: .leading) { Text(server.name) - .font(.caption) - .fontWeight(.bold) + .font(.caption.bold()) .foregroundStyle(.primary) Text(server.url.host ?? "") .font(.caption) diff --git a/ios/RocketChat Watch App/Views/ViewModifier.swift b/ios/RocketChat Watch App/Views/ViewModifier.swift deleted file mode 100644 index c222856d8..000000000 --- a/ios/RocketChat Watch App/Views/ViewModifier.swift +++ /dev/null @@ -1,35 +0,0 @@ -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 e355659fc..355f1150f 100644 --- a/ios/RocketChatRN.xcodeproj/project.pbxproj +++ b/ios/RocketChatRN.xcodeproj/project.pbxproj @@ -79,7 +79,6 @@ 1E470E832513A71E00E3DD1D /* RocketChat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E470E822513A71E00E3DD1D /* RocketChat.swift */; }; 1E4AFC152B5AF09800E2AA7D /* Dependency.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E4AFC142B5AF09800E2AA7D /* Dependency.swift */; }; 1E4AFC172B5AF09C00E2AA7D /* Store.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E4AFC162B5AF09C00E2AA7D /* Store.swift */; }; - 1E4AFC1B2B5AFC6A00E2AA7D /* Publisher+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E4AFC1A2B5AFC6A00E2AA7D /* Publisher+Extensions.swift */; }; 1E4AFC212B5B1AA000E2AA7D /* AppView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E4AFC202B5B1AA000E2AA7D /* AppView.swift */; }; 1E4AFC272B5B23C600E2AA7D /* RetryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E4AFC262B5B23C600E2AA7D /* RetryView.swift */; }; 1E51D962251263CD00DC95DE /* MessageType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E51D961251263CD00DC95DE /* MessageType.swift */; }; @@ -88,7 +87,6 @@ 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 */; }; @@ -394,7 +392,6 @@ 1E470E822513A71E00E3DD1D /* RocketChat.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RocketChat.swift; sourceTree = ""; }; 1E4AFC142B5AF09800E2AA7D /* Dependency.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Dependency.swift; sourceTree = ""; }; 1E4AFC162B5AF09C00E2AA7D /* Store.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Store.swift; sourceTree = ""; }; - 1E4AFC1A2B5AFC6A00E2AA7D /* Publisher+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Publisher+Extensions.swift"; sourceTree = ""; }; 1E4AFC202B5B1AA000E2AA7D /* AppView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppView.swift; sourceTree = ""; }; 1E4AFC262B5B23C600E2AA7D /* RetryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RetryView.swift; sourceTree = ""; }; 1E51D961251263CD00DC95DE /* MessageType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageType.swift; sourceTree = ""; }; @@ -403,7 +400,6 @@ 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 = ""; }; @@ -665,7 +661,6 @@ children = ( 1E29A3092B585B370093C03C /* Data+Extensions.swift */, 1E29A30B2B585D1D0093C03C /* String+Extensions.swift */, - 1E4AFC1A2B5AFC6A00E2AA7D /* Publisher+Extensions.swift */, 1E638E9D2B5F0F5800E645E4 /* URL+Extensions.swift */, ); path = Extensions; @@ -800,7 +795,6 @@ 1E4AFC262B5B23C600E2AA7D /* RetryView.swift */, 1EDB30F12B5B453A00532C7E /* LoggedInView.swift */, 1E638E982B5F0A2900E645E4 /* ChatScrollView.swift */, - 1E638E9B2B5F0CFD00E645E4 /* ViewModifier.swift */, ); path = Views; sourceTree = ""; @@ -1872,7 +1866,6 @@ 1E9A716F2B59CBCA00477BA2 /* AttachmentView.swift in Sources */, 1E29A3002B585B070093C03C /* JSONAdapter.swift in Sources */, 1E29A3022B585B070093C03C /* DateCodingStrategy.swift in Sources */, - 1E4AFC1B2B5AFC6A00E2AA7D /* Publisher+Extensions.swift in Sources */, 1E4AFC272B5B23C600E2AA7D /* RetryView.swift in Sources */, 1ED033B62B55B4A5004F4930 /* ServerListView.swift in Sources */, 1E29A3202B5871C80093C03C /* RoomFormatter.swift in Sources */, @@ -1899,7 +1892,6 @@ 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 */,