Rename screens (#826)

* Rename: AnalyticsPrompt -> AnalyticsPromptScreen

* Rename: AnalyticsSettings -> AnalyticsSettingsScreen

* Rename: Settings -> SettingsScreen

* Rename: SessionVerification -> SessionVerificationScreen

* Rename: BugReport -> BugReportScreen

* Rename: FilePreview -> FilePreviewScreen

* Rename: AnalyticsPrompt -> AnalyticsPromptScreen

* Rename: Invites -> InvitesScreen

* Rename: InviteUsers -> InviteUsersScreen

* Rename: MediaPicker -> MediaPickerScreen

* Delete unused UIActivityViewControllerWrapper

* Rename: ReportContent -> ReportContentScreen

* Rename: RoomDetails -> RoomDetailsScreen

* Rename: RoomMemberDetails -> RoomMemberDetailsScreen

* Rename: RoomMemberList -> RoomMemberListScreen

* Rename: Cleanup

* Renaming missed items

* Low effort attempt at fixing the flakey unit tests
This commit is contained in:
Stefan Ceriu
2023-04-24 18:48:07 +03:00
committed by GitHub
parent 9911ad2b9b
commit 24572c6582
88 changed files with 492 additions and 520 deletions
@@ -0,0 +1,50 @@
//
// Copyright 2021 New Vector Ltd
//
// 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 SwiftUI
final class AnalyticsPromptScreenCoordinator: CoordinatorProtocol {
private var viewModel: AnalyticsPromptScreenViewModel
var callback: (@MainActor () -> Void)?
init() {
viewModel = AnalyticsPromptScreenViewModel()
}
// MARK: - Public
func start() {
viewModel.callback = { [weak self] result in
guard let self else { return }
switch result {
case .enable:
MXLog.info("Enable Analytics")
ServiceLocator.shared.analytics.optIn()
self.callback?()
case .disable:
MXLog.info("Disable Analytics")
ServiceLocator.shared.analytics.optOut()
self.callback?()
}
}
}
func toPresentable() -> AnyView {
AnyView(AnalyticsPromptScreen(context: viewModel.context))
}
}
@@ -0,0 +1,55 @@
//
// Copyright 2021 New Vector Ltd
//
// 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
enum AnalyticsPromptScreenViewAction {
/// Enable analytics.
case enable
/// Disable analytics.
case disable
}
enum AnalyticsPromptScreenViewModelAction {
/// Enable analytics.
case enable
/// Disable analytics.
case disable
}
struct AnalyticsPromptScreenViewState: BindableState {
/// Attributed strings created from localized HTML.
let strings: AnalyticsPromptScreenStrings
}
/// A collection of strings for the UI that need to be parsed from HTML
struct AnalyticsPromptScreenStrings {
let optInContent: AttributedString
let point1 = AttributedStringBuilder().fromHTML(L10n.screenAnalyticsPromptDataUsage) ?? AttributedString(L10n.screenAnalyticsPromptDataUsage)
let point2 = AttributedStringBuilder().fromHTML(L10n.screenAnalyticsPromptThirdPartySharing) ?? AttributedString(L10n.screenAnalyticsPromptThirdPartySharing)
let point3 = L10n.screenAnalyticsPromptSettings
init(termsURL: URL) {
let content = AttributedString(L10n.screenAnalyticsPromptHelpUsImprove(InfoPlistReader.main.bundleDisplayName))
// Create the opt in content with a placeholder.
let linkPlaceholder = "{link}"
var readTerms = AttributedString(L10n.screenAnalyticsPromptReadTerms(linkPlaceholder))
readTerms.replace(linkPlaceholder,
with: L10n.screenAnalyticsPromptReadTermsContentLink,
asLinkTo: termsURL)
optInContent = content + "\n\n" + readTerms
}
}
@@ -0,0 +1,41 @@
//
// Copyright 2021 New Vector Ltd
//
// 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 Combine
import SwiftUI
typealias AnalyticsPromptScreenViewModelType = StateStoreViewModel<AnalyticsPromptScreenViewState, AnalyticsPromptScreenViewAction>
class AnalyticsPromptScreenViewModel: AnalyticsPromptScreenViewModelType, AnalyticsPromptScreenViewModelProtocol {
var callback: (@MainActor (AnalyticsPromptScreenViewModelAction) -> Void)?
/// Initialize a view model with the specified prompt type and app display name.
init() {
let promptStrings = AnalyticsPromptScreenStrings(termsURL: ServiceLocator.shared.settings.analyticsConfiguration.termsURL)
super.init(initialViewState: AnalyticsPromptScreenViewState(strings: promptStrings))
}
// MARK: - Public
override func process(viewAction: AnalyticsPromptScreenViewAction) {
switch viewAction {
case .enable:
callback?(.enable)
case .disable:
callback?(.disable)
}
}
}
@@ -0,0 +1,23 @@
//
// Copyright 2021 New Vector Ltd
//
// 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
@MainActor
protocol AnalyticsPromptScreenViewModelProtocol {
var callback: (@MainActor (AnalyticsPromptScreenViewModelAction) -> Void)? { get set }
var context: AnalyticsPromptScreenViewModelType.Context { get }
}
@@ -0,0 +1,123 @@
//
// Copyright 2021 New Vector Ltd
//
// 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 SwiftUI
/// A prompt that asks the user whether they would like to enable Analytics or not.
struct AnalyticsPromptScreen: View {
private let horizontalPadding: CGFloat = 16
@ObservedObject var context: AnalyticsPromptScreenViewModel.Context
var body: some View {
GeometryReader { geometry in
ScrollView {
Spacer()
.frame(height: UIConstants.spacerHeight(in: geometry))
mainContent
.readableFrame()
.padding(.horizontal, horizontalPadding)
.padding(.top, UIConstants.onboardingBreakerScreenTopPadding)
.padding(.bottom, 8)
}
.safeAreaInset(edge: .bottom) {
VStack {
buttons
.readableFrame()
.padding(.horizontal, horizontalPadding)
.padding(.bottom, UIConstants.actionButtonBottomPadding)
Spacer()
.frame(height: UIConstants.spacerHeight(in: geometry))
}
.padding(.top, 8)
.background(Color.element.background.ignoresSafeArea())
}
.background(Color.element.background.ignoresSafeArea())
}
.navigationBarHidden(true)
.navigationBarBackButtonHidden(true)
}
/// The main content of the screen that is shown inside the scroll view.
private var mainContent: some View {
VStack {
Image(uiImage: Asset.Images.analyticsLogo.image)
.padding(.bottom, 24)
Text(L10n.screenAnalyticsPromptTitle(InfoPlistReader.main.bundleDisplayName))
.font(.element.title2Bold)
.multilineTextAlignment(.center)
.foregroundColor(.element.primaryContent)
.padding(.bottom, 2)
.accessibilityIdentifier(A11yIdentifiers.analyticsPromptScreen.title)
Text(context.viewState.strings.optInContent)
.font(.element.body)
.multilineTextAlignment(.center)
.foregroundColor(.element.secondaryContent)
.tint(.element.links)
Divider()
.background(Color.element.quinaryContent)
.padding(.vertical, 20)
checkmarkList
}
}
/// The list of re-assurances about analytics.
private var checkmarkList: some View {
VStack(alignment: .leading, spacing: 8) {
AnalyticsPromptScreenCheckmarkItem(attributedString: context.viewState.strings.point1)
AnalyticsPromptScreenCheckmarkItem(attributedString: context.viewState.strings.point2)
AnalyticsPromptScreenCheckmarkItem(string: context.viewState.strings.point3)
}
.fixedSize(horizontal: false, vertical: true)
.font(.element.body)
.foregroundColor(.element.secondaryContent)
.frame(maxWidth: .infinity)
}
/// The stack of enable/disable buttons.
private var buttons: some View {
VStack {
Button { context.send(viewAction: .enable) } label: {
Text(L10n.actionEnable)
.font(.element.bodyBold)
}
.buttonStyle(.elementAction(.xLarge))
.accessibilityIdentifier(A11yIdentifiers.analyticsPromptScreen.enable)
Button { context.send(viewAction: .disable) } label: {
Text(L10n.actionNotNow)
.font(.element.bodyBold)
.padding(12)
}
.accessibilityIdentifier(A11yIdentifiers.analyticsPromptScreen.notNow)
}
}
}
// MARK: - Previews
struct AnalyticsPromptScreen_Previews: PreviewProvider {
static let viewModel = AnalyticsPromptScreenViewModel()
static var previews: some View {
AnalyticsPromptScreen(context: viewModel.context)
}
}
@@ -0,0 +1,52 @@
//
// Copyright 2021 New Vector Ltd
//
// 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 SwiftUI
struct AnalyticsPromptScreenCheckmarkItem: View {
private let attributedString: AttributedString
init(attributedString: AttributedString) {
self.attributedString = attributedString
}
init(string: String) {
attributedString = AttributedString(string)
}
var body: some View {
Label { Text(attributedString) } icon: {
Image(systemName: "checkmark.circle")
.foregroundColor(.element.accent)
}
}
}
// MARK: - Previews
struct AnalyticsPromptScreenCheckmarkItem_Previews: PreviewProvider {
static let strings = AnalyticsPromptScreenStrings(termsURL: ServiceLocator.shared.settings.analyticsConfiguration.termsURL)
static var previews: some View {
VStack(alignment: .leading) {
AnalyticsPromptScreenCheckmarkItem(attributedString: strings.point1)
AnalyticsPromptScreenCheckmarkItem(attributedString: strings.point2)
AnalyticsPromptScreenCheckmarkItem(attributedString: AttributedString("This is a short string."))
AnalyticsPromptScreenCheckmarkItem(attributedString: AttributedString("This is a very long string that will be used to test the layout over multiple lines of text to ensure everything is correct."))
}
.padding()
}
}