Replace the Report a Problem button with the app's version on the start screen. (#4262)

Tapping it 7-times will secretly reveal the bug report screen 🤫
This commit is contained in:
Doug
2025-06-27 10:09:35 +01:00
committed by GitHub
parent d2bfcf81d2
commit e0914e4889
25 changed files with 61 additions and 67 deletions
+4
View File
@@ -1782,6 +1782,10 @@ internal enum L10n {
internal static var screenNotificationSettingsSystemNotificationsTurnedOff: String { return L10n.tr("Localizable", "screen_notification_settings_system_notifications_turned_off") }
/// Notifications
internal static var screenNotificationSettingsTitle: String { return L10n.tr("Localizable", "screen_notification_settings_title") }
/// Version %1$@
internal static func screenOnboardingAppVersion(_ p1: Any) -> String {
return L10n.tr("Localizable", "screen_onboarding_app_version", String(describing: p1))
}
/// Sign in manually
internal static var screenOnboardingSignInManually: String { return L10n.tr("Localizable", "screen_onboarding_sign_in_manually") }
/// Sign in to %1$@
@@ -123,14 +123,14 @@ enum A11yIdentifiers {
struct AuthenticationStartScreen {
let signIn = "authentication_start-sign_in"
let signInWithQr = "authentication_start-sign_in_with_qr"
let reportAProblem = "authentication_start-report_a_problem"
let appVersion = "authentication_start-app_version"
let hidden = "authentication_start-hidden"
}
struct ReportContent {
let ignoreUser = "report_content-ignore_user"
}
struct RoomScreen {
let name = "room-name"
let avatar = "room-avatar"
@@ -36,7 +36,6 @@ struct AuthenticationStartScreenViewState: BindableState {
let serverName: String?
let showCreateAccountButton: Bool
let showQRCodeLoginButton: Bool
let showReportProblemButton: Bool
var bindings = AuthenticationStartScreenViewStateBindings()
@@ -16,6 +16,8 @@ class AuthenticationStartScreenViewModel: AuthenticationStartScreenViewModelType
private let appSettings: AppSettings
private let userIndicatorController: UserIndicatorControllerProtocol
private let canReportProblem: Bool
private var actionsSubject: PassthroughSubject<AuthenticationStartScreenViewModelAction, Never> = .init()
var actions: AnyPublisher<AuthenticationStartScreenViewModelAction, Never> {
@@ -31,6 +33,7 @@ class AuthenticationStartScreenViewModel: AuthenticationStartScreenViewModelType
self.provisioningParameters = provisioningParameters
self.appSettings = appSettings
self.userIndicatorController = userIndicatorController
canReportProblem = isBugReportServiceEnabled
let isQRCodeScanningSupported = !ProcessInfo.processInfo.isiOSAppOnMac
@@ -39,20 +42,17 @@ class AuthenticationStartScreenViewModel: AuthenticationStartScreenViewModelType
// The assumption here being that if you're running a custom app, your users will already be created.
AuthenticationStartScreenViewState(serverName: appSettings.accountProviders.count == 1 ? appSettings.accountProviders[0] : nil,
showCreateAccountButton: false,
showQRCodeLoginButton: isQRCodeScanningSupported,
showReportProblemButton: isBugReportServiceEnabled)
showQRCodeLoginButton: isQRCodeScanningSupported)
} else if let provisioningParameters {
// We only show the "Sign in to …" button when using a provisioning link.
AuthenticationStartScreenViewState(serverName: provisioningParameters.accountProvider,
showCreateAccountButton: false,
showQRCodeLoginButton: false,
showReportProblemButton: isBugReportServiceEnabled)
showQRCodeLoginButton: false)
} else {
// The default configuration.
AuthenticationStartScreenViewState(serverName: nil,
showCreateAccountButton: appSettings.showCreateAccountButton,
showQRCodeLoginButton: isQRCodeScanningSupported,
showReportProblemButton: isBugReportServiceEnabled)
showQRCodeLoginButton: isQRCodeScanningSupported)
}
super.init(initialViewState: initialViewState)
@@ -70,7 +70,9 @@ class AuthenticationStartScreenViewModel: AuthenticationStartScreenViewModelType
case .register:
actionsSubject.send(.register)
case .reportProblem:
actionsSubject.send(.reportProblem)
if canReportProblem {
actionsSubject.send(.reportProblem)
}
}
}
@@ -35,18 +35,15 @@ struct AuthenticationStartScreen: View {
}
.frame(maxHeight: .infinity)
.safeAreaInset(edge: .bottom) {
if context.viewState.showReportProblemButton {
Button {
versionText
.font(.compound.bodySM)
.foregroundColor(.compound.textSecondary)
.frame(maxWidth: .infinity)
.padding(.bottom)
.onTapGesture(count: 7) {
context.send(viewAction: .reportProblem)
} label: {
Text(L10n.commonReportAProblem)
.font(.compound.bodySM)
.foregroundColor(.compound.textSecondary)
.padding(.bottom)
}
.frame(width: geometry.size.width)
.accessibilityIdentifier(A11yIdentifiers.authenticationStartScreen.reportAProblem)
}
.accessibilityIdentifier(A11yIdentifiers.authenticationStartScreen.appVersion)
}
}
.navigationBarHidden(true)
@@ -117,28 +114,31 @@ struct AuthenticationStartScreen: View {
.padding(.horizontal, verticalSizeClass == .compact ? 128 : 24)
.readableFrame()
}
var versionText: Text {
// Let's not deal with snapshotting a changing version string.
let shortVersionString = ProcessInfo.isRunningTests ? "0.0.0" : InfoPlistReader.main.bundleShortVersionString
return Text(L10n.screenOnboardingAppVersion(shortVersionString))
}
}
// MARK: - Previews
struct AuthenticationStartScreen_Previews: PreviewProvider, TestablePreview {
static let viewModel = makeViewModel()
static let bugReportDisabledViewModel = makeViewModel(isBugReportServiceEnabled: false)
static let provisionedViewModel = makeViewModel(provisionedServerName: "example.com")
static var previews: some View {
AuthenticationStartScreen(context: viewModel.context)
.previewDisplayName("Default")
AuthenticationStartScreen(context: bugReportDisabledViewModel.context)
.previewDisplayName("Bug report disabled")
AuthenticationStartScreen(context: provisionedViewModel.context)
.previewDisplayName("Provisioned")
}
static func makeViewModel(isBugReportServiceEnabled: Bool = true, provisionedServerName: String? = nil) -> AuthenticationStartScreenViewModel {
static func makeViewModel(provisionedServerName: String? = nil) -> AuthenticationStartScreenViewModel {
AuthenticationStartScreenViewModel(authenticationService: AuthenticationService.mock,
provisioningParameters: provisionedServerName.map { .init(accountProvider: $0, loginHint: nil) },
isBugReportServiceEnabled: isBugReportServiceEnabled,
isBugReportServiceEnabled: true,
appSettings: ServiceLocator.shared.settings,
userIndicatorController: UserIndicatorControllerMock())
}