Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add beta disclaimer #1573

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions mobile/lib/common/application/switch.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import 'package:flutter/material.dart';
import 'package:get_10101/common/color.dart';

class TenTenOneSwitch extends StatefulWidget {
final bool value;
final ValueChanged<bool> onChanged;

const TenTenOneSwitch({Key? key, required this.value, required this.onChanged}) : super(key: key);

@override
State<TenTenOneSwitch> createState() => _TenTenOneSwitchState();
}

class _TenTenOneSwitchState extends State<TenTenOneSwitch> with SingleTickerProviderStateMixin {
Animation? _circleAnimation;
AnimationController? _animationController;

@override
void initState() {
super.initState();
_animationController =
AnimationController(vsync: this, duration: const Duration(milliseconds: 60));
_circleAnimation = AlignmentTween(
begin: widget.value ? Alignment.centerLeft : Alignment.centerRight,
end: widget.value ? Alignment.centerRight : Alignment.centerLeft)
.animate(CurvedAnimation(parent: _animationController!, curve: Curves.linear));
}

@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _animationController!,
builder: (context, child) {
return GestureDetector(
onTap: () {
if (_animationController!.isCompleted) {
_animationController!.reverse();
} else {
_animationController!.forward();
}
widget.value == false ? widget.onChanged(true) : widget.onChanged(false);
},
child: Container(
width: 50.0,
height: 30.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(24.0),
color: _circleAnimation!.value == Alignment.centerLeft
? tenTenOnePurple.shade300
: tenTenOnePurple.shade100),
child: Padding(
padding: const EdgeInsets.only(top: 6.0, bottom: 6.0, left: 5.0, right: 5.0),
child: Container(
alignment: widget.value
? ((Directionality.of(context) == TextDirection.rtl)
? Alignment.centerLeft
: Alignment.centerRight)
: ((Directionality.of(context) == TextDirection.rtl)
? Alignment.centerRight
: Alignment.centerLeft),
child: Container(
width: 20.0,
height: 20.0,
decoration: const BoxDecoration(shape: BoxShape.circle, color: Colors.white),
),
),
),
),
);
},
);
}
}
2 changes: 1 addition & 1 deletion mobile/lib/common/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ GoRouter createRoutes() {
path: LoadingScreen.route,
pageBuilder: (context, state) => NoTransitionPage<void>(
child: LoadingScreen(
restore: state.extra as Future<void>?,
future: state.extra as Future<void>?,
),
),
),
Expand Down
24 changes: 10 additions & 14 deletions mobile/lib/features/welcome/loading_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import 'package:go_router/go_router.dart';
class LoadingScreen extends StatefulWidget {
static const route = "/loading";

final Future<void>? restore;
final Future<void>? future;

const LoadingScreen({super.key, this.restore});
const LoadingScreen({super.key, this.future});

@override
State<LoadingScreen> createState() => _LoadingScreenState();
Expand All @@ -29,18 +29,14 @@ class _LoadingScreenState extends State<LoadingScreen> {

@override
void initState() {
List<Future<dynamic>> futures = [
Preferences.instance.getOpenPosition(),
isSeedFilePresent(),
Preferences.instance.isFullBackupRequired(),
];

if (widget.restore != null) {
// wait for the restore process to finish!
futures.add(widget.restore!);
}

Future.wait<dynamic>(futures).then((value) {
// Wait for the future to complete sequentially before running other futures concurrently
(widget.future ?? Future.value()).then((value) {
return Future.wait<dynamic>([
Preferences.instance.getOpenPosition(),
isSeedFilePresent(),
Preferences.instance.isFullBackupRequired(),
]);
}).then((value) {
final position = value[0];
final isSeedFilePresent = value[1];
final isFullBackupRequired = value[2];
Expand Down
41 changes: 2 additions & 39 deletions mobile/lib/features/welcome/onboarding.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart';
import 'package:get_10101/common/color.dart';
import 'package:get_10101/common/global_keys.dart';
import 'package:get_10101/common/snack_bar.dart';
import 'package:get_10101/features/welcome/seed_import_screen.dart';
import 'package:get_10101/features/welcome/welcome_screen.dart';
import 'package:get_10101/ffi.dart';
import 'package:get_10101/logger/logger.dart';
import 'package:get_10101/util/file.dart';
import 'package:get_10101/util/preferences.dart';
import 'package:go_router/go_router.dart';

final themeMode = ValueNotifier(2);
Expand Down Expand Up @@ -71,7 +65,6 @@ class Onboarding extends StatefulWidget {
class _Onboarding extends State<Onboarding> {
int _current = 0;
final CarouselController _controller = CarouselController();
bool buttonsDisabled = false;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -137,29 +130,7 @@ class _Onboarding extends State<Onboarding> {
SizedBox(
width: 250,
child: ElevatedButton(
onPressed: buttonsDisabled
? null
: () async {
setState(() {
buttonsDisabled = true;
});
final seedPath = await getSeedFilePath();
await api
.initNewMnemonic(targetSeedFilePath: seedPath)
.then((value) async {
Preferences.instance
.hasEmailAddress()
.then((value) => GoRouter.of(context).go(WelcomeScreen.route));
}).catchError((error) {
logger.e("Could not create seed", error: error);
showSnackBar(ScaffoldMessenger.of(rootNavigatorKey.currentContext!),
"Failed to create seed: $error");
// In case there was an error and we did not go forward, we want to be able to click the button again.
setState(() {
buttonsDisabled = false;
});
});
},
onPressed: () => GoRouter.of(context).go(WelcomeScreen.route),
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsets>(const EdgeInsets.all(15)),
backgroundColor: MaterialStateProperty.all<Color>(tenTenOnePurple),
Expand All @@ -183,15 +154,7 @@ class _Onboarding extends State<Onboarding> {
SizedBox(
width: 250,
child: TextButton(
onPressed: buttonsDisabled
? null
: () {
setState(() {
buttonsDisabled = true;
GoRouter.of(context).go(SeedPhraseImporter.route);
buttonsDisabled = false;
});
},
onPressed: () => GoRouter.of(context).go(SeedPhraseImporter.route),
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsets>(const EdgeInsets.all(15)),
backgroundColor: MaterialStateProperty.all<Color>(Colors.white),
Expand Down
Loading
Loading