mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-22 00:12:09 +03:00
remove Android Beta dialog
This commit is contained in:
parent
a424cb592d
commit
46cefcddba
Binary file not shown.
Before Width: | Height: | Size: 40 KiB |
Binary file not shown.
Before Width: | Height: | Size: 40 KiB |
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Yubico.
|
||||
*
|
||||
* 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 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:yubico_authenticator/android/keys.dart' as keys;
|
||||
|
||||
import '../android/util.dart' as android_test_util;
|
||||
import 'constants.dart';
|
||||
|
||||
void main() {
|
||||
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
||||
|
||||
group('Beta welcome dialog', () {
|
||||
testWidgets('shows welcome screen', (WidgetTester tester) async {
|
||||
await android_test_util.startUp(tester, {
|
||||
'dlg.beta.enabled': true,
|
||||
'needs_yubikey': false,
|
||||
});
|
||||
|
||||
expect(find.byKey(keys.betaDialogView), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('does not show welcome dialog', (WidgetTester tester) async {
|
||||
await android_test_util.startUp(tester, {
|
||||
'dlg.beta.enabled': false,
|
||||
'needs_yubikey': false,
|
||||
});
|
||||
expect(find.byKey(keys.betaDialogView), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('updates preferences', (WidgetTester tester) async {
|
||||
await android_test_util.startUp(tester, {
|
||||
'dlg.beta.enabled': true,
|
||||
'needs_yubikey': false,
|
||||
});
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
await tester.tap(find.byKey(keys.okButton));
|
||||
await expectLater(prefs.getBool(betaDialogPrefName), equals(false));
|
||||
});
|
||||
});
|
||||
}
|
@ -1,159 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Yubico.
|
||||
*
|
||||
* 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 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../app/message.dart';
|
||||
import '../../app/state.dart';
|
||||
import '../../core/state.dart';
|
||||
import '../keys.dart' as keys;
|
||||
|
||||
void requestBetaDialog(WidgetRef ref) async {
|
||||
const String prefBetaDialogShouldBeShown = 'prefBetaDialogShouldBeShown';
|
||||
var sharedPrefs = ref.read(prefProvider);
|
||||
await sharedPrefs.reload();
|
||||
var dialogShouldBeShown =
|
||||
sharedPrefs.getBool(prefBetaDialogShouldBeShown) ?? true;
|
||||
if (dialogShouldBeShown) {
|
||||
final withContext = ref.read(withContextProvider);
|
||||
|
||||
await withContext(
|
||||
(context) async {
|
||||
await showBlurDialog(
|
||||
context: context,
|
||||
builder: (context) => const _BetaDialog(),
|
||||
routeSettings: const RouteSettings(name: 'android_beta_dialog'),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
await sharedPrefs.setBool(prefBetaDialogShouldBeShown, false);
|
||||
}
|
||||
}
|
||||
|
||||
class _BetaDialog extends StatefulWidget {
|
||||
const _BetaDialog();
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _BetaDialogState();
|
||||
}
|
||||
|
||||
class _BetaDialogState extends State<_BetaDialog> {
|
||||
late FocusScopeNode _focus;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_focus = FocusScopeNode();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_focus.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// This keeps the focus in the dialog, even if the underlying page
|
||||
// changes as it does when a new device is selected.
|
||||
return FocusScope(
|
||||
node: _focus,
|
||||
autofocus: true,
|
||||
onFocusChange: (focused) {
|
||||
if (!focused) {
|
||||
_focus.requestFocus();
|
||||
}
|
||||
},
|
||||
child: const _BetaDialogContent(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _BetaDialogContent extends ConsumerWidget {
|
||||
const _BetaDialogContent();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final isDarkTheme = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: AlertDialog(
|
||||
key: keys.betaDialogView,
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Image.asset(
|
||||
isDarkTheme
|
||||
? 'assets/graphics/beta-dark.png'
|
||||
: 'assets/graphics/beta-light.png',
|
||||
alignment: Alignment.topCenter,
|
||||
height: 124,
|
||||
filterQuality: FilterQuality.medium,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
'Welcome to Yubico Authenticator Beta!',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineMedium
|
||||
?.copyWith(color: isDarkTheme ? Colors.white : Colors.black),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
const Text(
|
||||
'• Preview the latest beta: Try out the newest features. (Sometimes these may be a little rough around the edges.)'),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'• Give early feedback: Let us know what you think and help make Authenticator for Android a better experience. Go to “Send us feedback” under Help and about.'),
|
||||
],
|
||||
),
|
||||
actions: <Widget>[
|
||||
// FIXME: enable and add correct uri
|
||||
// TextButton(
|
||||
// style: TextButton.styleFrom(
|
||||
// textStyle: Theme.of(context)
|
||||
// .textTheme
|
||||
// .labelLarge
|
||||
// ?.copyWith(fontWeight: FontWeight.bold),
|
||||
// ),
|
||||
// child: const Text('Learn more'),
|
||||
// onPressed: () {
|
||||
// launchUrl(Uri.parse('https://learn more uri'),
|
||||
// mode: LaunchMode.externalApplication);
|
||||
// onBetaDialogClosed(context, ref);
|
||||
// },
|
||||
// ),
|
||||
TextButton(
|
||||
key: keys.okButton,
|
||||
style: TextButton.styleFrom(
|
||||
textStyle: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge
|
||||
?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
child: const Text('Got it'),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pop(true) //{}, //onBetaDialogClosed(context, ref),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -45,7 +45,6 @@ class MainPage extends ConsumerWidget {
|
||||
Navigator.of(context).popUntil((route) {
|
||||
return route.isFirst ||
|
||||
[
|
||||
'android_beta_dialog',
|
||||
'device_picker',
|
||||
'settings',
|
||||
'about',
|
||||
|
Loading…
Reference in New Issue
Block a user