From 93ec531e02c23992d14d4d3a804b3f7073b738e5 Mon Sep 17 00:00:00 2001 From: Arnfried Griesert Date: Thu, 30 Jun 2022 04:57:49 +0200 Subject: [PATCH] Accent color for personal state text editor --- .../Members/RoomParticipantsViewController.m | 4 +-- bwi/PersonalState/PersonalStateView.swift | 30 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Riot/Modules/Room/Members/RoomParticipantsViewController.m b/Riot/Modules/Room/Members/RoomParticipantsViewController.m index 084578bcc..e2df9221b 100644 --- a/Riot/Modules/Room/Members/RoomParticipantsViewController.m +++ b/Riot/Modules/Room/Members/RoomParticipantsViewController.m @@ -1117,8 +1117,8 @@ if (BuildSettings.bwiPersonalState && contact.mxMember.userId) { MXUser *user = [self.mxRoom.mxSession userWithUserId:contact.mxMember.userId]; - participantCell.contactInformationLabel.text = user.displayname; - participantCell.contactInformationLabel.hidden = user.displayname.length > 0; + participantCell.contactInformationLabel.text = user.statusMsg; + participantCell.contactInformationLabel.hidden = user.statusMsg.length <= 0; } } cell = participantCell; diff --git a/bwi/PersonalState/PersonalStateView.swift b/bwi/PersonalState/PersonalStateView.swift index 77a4ec27f..df243bc33 100644 --- a/bwi/PersonalState/PersonalStateView.swift +++ b/bwi/PersonalState/PersonalStateView.swift @@ -31,10 +31,10 @@ import SwiftUI @available(iOS 14.0, *) struct PersonalStateView: View { @Environment(\.presentationMode) var presentationMode - @State private var stateMessage: String = "" - @State private var oldStateMessage: String = "" + @State private var statusMessage: String = "" + @State private var oldStatusMessage: String = "" private var hasChanges: Bool { - return stateMessage.compare(oldStateMessage) != .orderedSame + return statusMessage.compare(oldStatusMessage) != .orderedSame } let session: MXSession? @@ -49,11 +49,11 @@ struct PersonalStateView: View { .multilineTextAlignment(.leading) HStack { - TextEditor(text: $stateMessage) + TextEditor(text: $statusMessage) .frame(height: 100) .border(Color.secondary, width: 1) - - + .accentColor(Color(ThemeService.shared().theme.tintColor)) + Button(action: clearTextField) { Image(systemName: "delete") } @@ -61,29 +61,29 @@ struct PersonalStateView: View { VStack(alignment: .center, spacing: 10) { Button { - stateMessage = NSLocalizedString("bwi_edit_personal_state_option_homeoffice", tableName: "Vector", comment: "") + statusMessage = NSLocalizedString("bwi_edit_personal_state_option_homeoffice", tableName: "Vector", comment: "") } label: { Text("bwi_edit_personal_state_option_homeoffice", tableName: "Vector") .foregroundColor(Color(ThemeService.shared().theme.tintColor)) } Button { - stateMessage = NSLocalizedString("bwi_edit_personal_state_option_work", tableName: "Vector", comment: "") + statusMessage = NSLocalizedString("bwi_edit_personal_state_option_work", tableName: "Vector", comment: "") } label: { Text("bwi_edit_personal_state_option_work", tableName: "Vector") .foregroundColor(Color(ThemeService.shared().theme.tintColor)) } Button { - stateMessage = NSLocalizedString("bwi_edit_personal_state_option_not_available", tableName: "Vector", comment: "") + statusMessage = NSLocalizedString("bwi_edit_personal_state_option_not_available", tableName: "Vector", comment: "") } label: { Text("bwi_edit_personal_state_option_not_available", tableName: "Vector") .foregroundColor(Color(ThemeService.shared().theme.tintColor)) } - if stateMessage.lengthOfBytes(using: .utf8) > 0 { + if statusMessage.lengthOfBytes(using: .utf8) > 0 { Button { - stateMessage = "" + statusMessage = "" } label: { Text("bwi_edit_personal_state_option_reset", tableName: "Vector") .foregroundColor(Color.red) @@ -108,19 +108,19 @@ struct PersonalStateView: View { } .onAppear{ if let account = MXKAccountManager.shared().activeAccounts.first { - stateMessage = account.userStatusMessage - oldStateMessage = account.userStatusMessage + statusMessage = account.userStatusMessage ?? "" + oldStatusMessage = account.userStatusMessage ?? "" } } } private func clearTextField() { - stateMessage = "" + statusMessage = "" } private func onDoneButton() { if let account = MXKAccountManager.shared().activeAccounts.first { - account.setUserPresence(.offline, andStatusMessage: stateMessage) { + account.setUserPresence(.offline, andStatusMessage: statusMessage) { } } self.presentationMode.wrappedValue.dismiss()