Merge branch 'feature/3681_second_birthday' into 'develop'

MESSENGER-3681 Updated birthday banner for second anniversary campaign

See merge request bwmessenger/bundesmessenger/bundesmessenger-ios!41
This commit is contained in:
Frank Rotermund
2022-11-16 13:32:05 +00:00
14 changed files with 375 additions and 832 deletions
@@ -29,12 +29,12 @@ import SwiftUI
// MARK: -
@available(iOS 14.0, *)
struct DeveloperSettingsView: View {
let session: MXSession?
@State private var showAlert = false
@State private var showAlertBirthdayCampaign = false
var body: some View {
List {
Button(action: { showAlert = createNewPersonalNotesRoom(mxSession: session) }) {
@@ -54,6 +54,14 @@ struct DeveloperSettingsView: View {
.alert(isPresented: $showAlert) {
Alert(title: Text(BWIL10n.bwiSettingsDeveloperShowMatomoPrivacyNotesResetted), message: Text(BWIL10n.bwiSettingsDeveloperShowMatomoPrivacyNotesResetted), dismissButton: .default(Text("Ok")))
}
Button(action: { showAlertBirthdayCampaign = resetBirthdayCampaignScreen(mxSession: session) }) {
Text(BWIL10n.bwiSettingsDeveloperSettingsResetBirthdayBanner)
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
.font(.system(size: 17))
}
.alert(isPresented: $showAlertBirthdayCampaign) {
Alert(title: Text(BWIL10n.bwiSettingsDeveloperSettingsBirthdayBannerResettetTitle), message: Text(BWIL10n.bwiSettingsDeveloperSettingsBirthdayBannerResettetMessage), dismissButton: .default(Text("Ok")))
}
Button(action: { _ = restrictUser(mxSession: session) }) {
Text(BWIL10n.bwiSettingsDeveloperRestrictUser)
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
@@ -101,6 +109,22 @@ fileprivate func resetMatomoInfoScreen() -> Bool {
return true
}
fileprivate func resetBirthdayCampaignScreen(mxSession: MXSession?) -> Bool {
guard let mxSession = mxSession else {
return false
}
let sharedSettings = RiotSharedSettings(session: mxSession)
let campaign = BWIBuildSettings.shared.bwiHappyBirthdayCampaignIdentifier
sharedSettings.setHappyBirthdayCampaign(campaign, enabled: true) {
} failure: { error in
if let error = error {
MXLog.debug("[HappyBirthdayCampaign] could not set flag in account data. Error: \(error)")
}
}
return true
}
fileprivate func restrictUser(mxSession: MXSession?) -> Bool {
guard let mxSession = mxSession else {
return false