|
| 1 | +import 'dart:async'; |
| 2 | + |
| 3 | +import 'package:flutter/foundation.dart'; |
1 | 4 | import 'package:flutter/material.dart';
|
2 | 5 |
|
3 | 6 | import '../generated/l10n/zulip_localizations.dart';
|
4 | 7 | import 'actions.dart';
|
| 8 | +import 'app.dart'; |
5 | 9 |
|
6 | 10 | Widget _dialogActionText(String text) {
|
7 | 11 | return Text(
|
@@ -112,3 +116,87 @@ DialogStatus<bool> showSuggestedActionDialog({
|
112 | 116 | ]));
|
113 | 117 | return DialogStatus(future);
|
114 | 118 | }
|
| 119 | + |
| 120 | +bool debugDisableBetaCompleteDialog = false; |
| 121 | + |
| 122 | +/// A brief dialog box saying that this beta channel has ended, |
| 123 | +/// offering a way to get the app from prod. |
| 124 | +/// |
| 125 | +/// Shown on every startup. |
| 126 | +class BetaCompleteDialog extends StatelessWidget { |
| 127 | + const BetaCompleteDialog._(); |
| 128 | + |
| 129 | + static void show() async { |
| 130 | + if (debugDisableBetaCompleteDialog) return; |
| 131 | + |
| 132 | + final navigator = await ZulipApp.navigator; |
| 133 | + final context = navigator.context; |
| 134 | + assert(context.mounted); |
| 135 | + if (!context.mounted) return; // TODO(linter): this is impossible as there's no actual async gap, but the use_build_context_synchronously lint doesn't see that |
| 136 | + |
| 137 | + switch (defaultTargetPlatform) { |
| 138 | + case TargetPlatform.android: |
| 139 | + case TargetPlatform.iOS: |
| 140 | + break; |
| 141 | + case TargetPlatform.macOS: |
| 142 | + case TargetPlatform.fuchsia: |
| 143 | + case TargetPlatform.linux: |
| 144 | + case TargetPlatform.windows: |
| 145 | + // Do nothing on these unsupported platforms. |
| 146 | + return; |
| 147 | + } |
| 148 | + |
| 149 | + unawaited(showDialog( |
| 150 | + context: context, |
| 151 | + builder: (BuildContext context) => BetaCompleteDialog._())); |
| 152 | + } |
| 153 | + |
| 154 | + Widget _linkButton(BuildContext context, { |
| 155 | + required String url, |
| 156 | + required String label, |
| 157 | + }) { |
| 158 | + return TextButton( |
| 159 | + onPressed: () { |
| 160 | + Navigator.pop(context); |
| 161 | + PlatformActions.launchUrl(context, |
| 162 | + Uri.parse(url)); |
| 163 | + }, |
| 164 | + child: _dialogActionText(label)); |
| 165 | + } |
| 166 | + |
| 167 | + @override |
| 168 | + Widget build(BuildContext context) { |
| 169 | + final message = 'Thanks for being a beta tester of the new Zulip app!' |
| 170 | + ' This app became the main Zulip mobile app in June 2025,' |
| 171 | + ' and this beta version is no longer maintained.' |
| 172 | + ' We recommend uninstalling this beta after switching' |
| 173 | + ' to the main Zulip app, in order to get the latest features' |
| 174 | + ' and bug fixes.'; |
| 175 | + |
| 176 | + return AlertDialog( |
| 177 | + title: Text('Time to switch to the new app'), |
| 178 | + content: SingleChildScrollView(child: Text(message)), |
| 179 | + actions: [ |
| 180 | + TextButton( |
| 181 | + onPressed: () => Navigator.pop(context), |
| 182 | + child: _dialogActionText('Got it')), |
| 183 | + ...(switch (defaultTargetPlatform) { |
| 184 | + TargetPlatform.android => [ |
| 185 | + _linkButton(context, |
| 186 | + url: 'https://github.com/zulip/zulip-flutter/releases/latest', |
| 187 | + label: 'Download official APKs (less common)'), |
| 188 | + _linkButton(context, |
| 189 | + url: 'https://play.google.com/store/apps/details?id=com.zulipmobile', |
| 190 | + label: 'Open Google Play Store'), |
| 191 | + ], |
| 192 | + TargetPlatform.iOS => [ |
| 193 | + _linkButton(context, |
| 194 | + url: 'https://apps.apple.com/app/zulip/id1203036395', |
| 195 | + label: 'Open App Store'), |
| 196 | + ], |
| 197 | + TargetPlatform.macOS || TargetPlatform.fuchsia |
| 198 | + || TargetPlatform.linux || TargetPlatform.windows => throw UnimplementedError(), |
| 199 | + }), |
| 200 | + ]); |
| 201 | + } |
| 202 | +} |
0 commit comments