diff --git a/Riot/Modules/Home/AllChats/AllChatsViewController.swift b/Riot/Modules/Home/AllChats/AllChatsViewController.swift index d29c18777..be13ab17d 100644 --- a/Riot/Modules/Home/AllChats/AllChatsViewController.swift +++ b/Riot/Modules/Home/AllChats/AllChatsViewController.swift @@ -495,13 +495,14 @@ class AllChatsViewController: HomeViewController { // bwi: 5706 show federation announcement promt func bwiCheckForFederationAnnouncementPromt() { - if AppConfigService.shared.shouldShowFederationAnnouncement() { + if self.mainSession.homeserverWellknown.shouldShowFederationAnnouncement() { let sharedSettings = RiotSharedSettings(session: self.mainSession) if sharedSettings.shouldShowFederationAnnouncement() { let viewController = FederationAnnouncementSheet().makeViewController() viewController.modalPresentationStyle = .formSheet - self.present(viewController, animated: true, completion: nil) - sharedSettings.setFederationAnnouncement() + self.present(viewController, animated: true) { + sharedSettings.setFederationAnnouncement() + } } } } diff --git a/bwi/AppConfig/AppConfig.swift b/bwi/AppConfig/AppConfig.swift index b16537150..3f5eb85ff 100644 --- a/bwi/AppConfig/AppConfig.swift +++ b/bwi/AppConfig/AppConfig.swift @@ -24,5 +24,4 @@ struct AppConfig: Codable, Equatable { var pusherUrl: String? = nil var permalinkUrl: String? = nil var externalUrlScheme: String? = nil - var shouldShowFederationAnnouncement: Bool? = false } diff --git a/bwi/AppConfig/AppConfigService.swift b/bwi/AppConfig/AppConfigService.swift index 4f82c0aef..62faca5a5 100644 --- a/bwi/AppConfig/AppConfigService.swift +++ b/bwi/AppConfig/AppConfigService.swift @@ -148,9 +148,6 @@ extension UserDefaults if let externalUrlScheme = dict[externalUrlSchemeKey] as? String { config.externalUrlScheme = externalUrlScheme } - if let shouldShowFederationAnnouncement = dict[federationAnnouncementKey] as? Bool { - config.shouldShowFederationAnnouncement = shouldShowFederationAnnouncement - } // app config needs at least a valid server url if let serverUrl = config.serverUrl { @@ -206,7 +203,4 @@ extension UserDefaults return appConfig.externalUrlScheme } - func shouldShowFederationAnnouncement() -> Bool { - return appConfig.shouldShowFederationAnnouncement ?? false - } } diff --git a/bwi/Federation/UI/FederationAnnouncementView.swift b/bwi/Federation/UI/FederationAnnouncementView.swift index 188751d52..7605f3f8b 100644 --- a/bwi/Federation/UI/FederationAnnouncementView.swift +++ b/bwi/Federation/UI/FederationAnnouncementView.swift @@ -48,7 +48,8 @@ struct FederationAnnouncementView: View { let imageStackScale = 0.30 let imageStackShift = 5.0 - let lineWith = 7.0 + let outerLineWith = 5.0 + let innerLineWith = 1.0 let spacing = 16.0 var announcementText: AttributedString { @@ -69,14 +70,19 @@ struct FederationAnnouncementView: View { ZStack(alignment: .center) { Circle() .fill(Color(theme.colors.quinaryContent)) - .overlay(Circle() - .stroke(Color(theme.colors.background), lineWidth: lineWith)) + .padding(outerLineWith) .offset(x:((getImageSize(width: geo.size.width, height: geo.size.height) * imageStackScale) / imageStackShift)) - Image("welcome_experience_1") + + Image(uiImage: Asset.SharedImages.loginFlowLogo.image) .resizable() + .aspectRatio(contentMode: .fill) + .clipShape(Circle()) + .padding(innerLineWith) + .background(Color(theme.colors.quinaryContent)) + .clipShape(Circle()) + .padding(outerLineWith) + .background(Color(ThemeService.shared().theme.backgroundColor)) .clipShape(Circle()) - .overlay(Circle() - .stroke(Color(theme.colors.background), lineWidth: lineWith)) .offset(x:-((getImageSize(width: geo.size.width, height: geo.size.height) * imageStackScale) / imageStackShift)) } .frame(width: getImageSize(width: geo.size.width, height: geo.size.height) * imageStackScale, height: getImageSize(width: geo.size.width, height: geo.size.height) * imageStackScale) diff --git a/bwi/Federation/UI/RoomFederationDecisionView.swift b/bwi/Federation/UI/RoomFederationDecisionView.swift index 6131fffc5..217b371be 100644 --- a/bwi/Federation/UI/RoomFederationDecisionView.swift +++ b/bwi/Federation/UI/RoomFederationDecisionView.swift @@ -59,7 +59,8 @@ struct RoomFederationDecisionView: View { var roomAvatarImage: UIImage let imageStackScale = 0.30 let imageStackShift = 5.0 - let lineWith = 7.0 + let outerLineWith = 5.0 + let innerLineWith = 1.0 let spacing = 16.0 @@ -73,14 +74,17 @@ struct RoomFederationDecisionView: View { ZStack(alignment: .center) { Circle() .fill(Color(theme.colors.quinaryContent)) - .overlay(Circle() - .stroke(Color(theme.colors.background), lineWidth: lineWith)) + .padding(outerLineWith) .offset(x:((getImageSize(width: geo.size.width, height: geo.size.height) * imageStackScale) / imageStackShift)) Image(uiImage: roomAvatarImage) .resizable() .clipShape(Circle()) - .overlay(Circle() - .stroke(Color(theme.colors.background), lineWidth: lineWith)) + .padding(innerLineWith) + .background(Color(theme.colors.quinaryContent)) + .clipShape(Circle()) + .padding(outerLineWith) + .background(Color(ThemeService.shared().theme.backgroundColor)) + .clipShape(Circle()) .offset(x:-((getImageSize(width: geo.size.width, height: geo.size.height) * imageStackScale) / imageStackShift)) } .frame(width: getImageSize(width: geo.size.width, height: geo.size.height) * imageStackScale, height: getImageSize(width: geo.size.width, height: geo.size.height) * imageStackScale) diff --git a/bwi/Wellknown/Wellknown+Bwi.swift b/bwi/Wellknown/Wellknown+Bwi.swift index ae290aada..fe22f0d35 100644 --- a/bwi/Wellknown/Wellknown+Bwi.swift +++ b/bwi/Wellknown/Wellknown+Bwi.swift @@ -112,4 +112,22 @@ public extension MXWellKnown { return nil } } + + @objc func shouldShowFederationAnnouncement() -> Bool { + do { + guard let bwiDict = self.jsonDictionary()["de.bwi"] as? [String : Any] else { + return false + } + + let bwi = try WellknownBWI(dict: bwiDict) + if let federation = bwi.federation { + return federation.showAnnouncement ?? false + } else { + return false + } + } + catch { + return false + } + } } diff --git a/bwi/Wellknown/WellknownBWI.swift b/bwi/Wellknown/WellknownBWI.swift index 6b166a20a..93ef95300 100644 --- a/bwi/Wellknown/WellknownBWI.swift +++ b/bwi/Wellknown/WellknownBWI.swift @@ -20,6 +20,7 @@ import Foundation struct WellknownBWI { let dataPrivacyURL: String? let imprintURL: String? + let federation: WellknownFederation? init(dict: [String: Any]) throws { let jsonData = try JSONSerialization.data(withJSONObject: dict, options: []) @@ -32,5 +33,6 @@ extension WellknownBWI: Decodable { enum CodingKeys: String, CodingKey { case dataPrivacyURL = "data_privacy_url" case imprintURL = "imprint_url" + case federation = "federation" } } diff --git a/bwi/Wellknown/WellknownFederation.swift b/bwi/Wellknown/WellknownFederation.swift new file mode 100644 index 000000000..b553a5891 --- /dev/null +++ b/bwi/Wellknown/WellknownFederation.swift @@ -0,0 +1,42 @@ +// +/* + * Copyright (c) 2024 BWI GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Foundation +struct WellknownFederation { + /// show federation announcement + let showAnnouncement: Bool? + + /// show federation tutorial (3 screens) + let showIntroduction: Bool + + /// enables the federation feature for the app - show federation views, activate invitation rules, show federation settings + let enable: Bool + + init(dict: [String: Any]) throws { + let jsonData = try JSONSerialization.data(withJSONObject: dict, options: []) + let decoder = JSONDecoder() + self = try decoder.decode(Self.self, from: jsonData) + } +} + +extension WellknownFederation: Decodable { + enum CodingKeys: String, CodingKey { + case showAnnouncement = "show_announcement" + case showIntroduction = "show_introduction" + case enable = "enable" + } +}