stack_wallet/lib/pages/intro_view.dart

321 lines
10 KiB
Dart
Raw Normal View History

2023-05-26 21:21:16 +00:00
/*
* This file is part of Stack Wallet.
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
* Generated by Cypher Stack on 2023-05-26
*
*/
import 'dart:io';
2022-08-26 08:11:35 +00:00
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
2023-04-25 22:07:28 +00:00
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
2022-10-07 23:13:02 +00:00
import 'package:stackwallet/pages/stack_privacy_calls.dart';
import 'package:stackwallet/pages_desktop_specific/password/create_password_view.dart';
import 'package:stackwallet/themes/stack_colors.dart';
2023-04-25 22:07:28 +00:00
import 'package:stackwallet/themes/theme_providers.dart';
import 'package:stackwallet/utilities/prefs.dart';
2022-08-26 08:11:35 +00:00
import 'package:stackwallet/utilities/text_styles.dart';
2022-09-19 20:18:31 +00:00
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
2022-08-26 08:11:35 +00:00
import 'package:url_launcher/url_launcher.dart';
2023-04-25 22:07:28 +00:00
class IntroView extends ConsumerStatefulWidget {
2022-08-26 08:11:35 +00:00
const IntroView({Key? key}) : super(key: key);
2022-10-09 19:28:39 +00:00
static const String routeName = "/introView";
2022-08-26 08:11:35 +00:00
@override
2023-04-25 22:07:28 +00:00
ConsumerState<IntroView> createState() => _IntroViewState();
2022-08-26 08:11:35 +00:00
}
2023-04-25 22:07:28 +00:00
class _IntroViewState extends ConsumerState<IntroView> {
late final bool isDesktop;
2022-08-26 08:11:35 +00:00
@override
void initState() {
2022-09-19 20:18:31 +00:00
isDesktop = Util.isDesktop;
2022-08-26 08:11:35 +00:00
super.initState();
}
@override
Widget build(BuildContext context) {
debugPrint("BUILD: $runtimeType ");
return Background(
child: Scaffold(
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
body: Center(
child: !isDesktop
? Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Spacer(
flex: 2,
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16,
),
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 300,
),
child: SvgPicture.file(
File(
ref.watch(
themeProvider.select(
(value) => value.assets.stack,
),
2023-04-25 22:09:45 +00:00
),
),
2023-03-13 14:52:54 +00:00
width: isDesktop ? 324 : 266,
height: isDesktop ? 324 : 266,
),
2022-08-26 08:11:35 +00:00
),
),
const Spacer(
flex: 1,
2022-08-26 08:11:35 +00:00
),
AppNameText(
isDesktop: isDesktop,
2022-08-26 08:11:35 +00:00
),
const SizedBox(
height: 8,
2022-08-26 08:11:35 +00:00
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 48,
),
child: IntroAboutText(
isDesktop: isDesktop,
),
2022-08-26 08:11:35 +00:00
),
const Spacer(
flex: 4,
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 32,
),
child: PrivacyAndTOSText(
isDesktop: isDesktop,
),
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 16,
),
child: Row(
children: [
Expanded(
child: GetStartedButton(
isDesktop: isDesktop,
),
),
],
),
2022-08-26 08:11:35 +00:00
),
],
)
: SizedBox(
width: 350,
height: 540,
child: Column(
children: [
const Spacer(
flex: 2,
),
SizedBox(
width: 130,
height: 130,
child: SvgPicture.file(
File(
ref.watch(
themeProvider.select(
(value) => value.assets.stackIcon,
),
2023-04-25 22:07:28 +00:00
),
),
),
),
const Spacer(
flex: 42,
),
AppNameText(
isDesktop: isDesktop,
),
const Spacer(
flex: 24,
),
IntroAboutText(
isDesktop: isDesktop,
),
const Spacer(
flex: 42,
),
GetStartedButton(
isDesktop: isDesktop,
),
if (isDesktop)
const SizedBox(
height: 20,
),
if (isDesktop)
SecondaryButton(
label: "Restore from Stack backup",
onPressed: () {
Navigator.of(context).pushNamed(
CreatePasswordView.routeName,
arguments: true,
);
},
),
const Spacer(
flex: 65,
),
PrivacyAndTOSText(
isDesktop: isDesktop,
),
],
),
2022-08-26 08:11:35 +00:00
),
),
),
);
}
}
class AppNameText extends StatelessWidget {
const AppNameText({Key? key, required this.isDesktop}) : super(key: key);
final bool isDesktop;
@override
Widget build(BuildContext context) {
return Text(
"Stack Wallet",
textAlign: TextAlign.center,
style: !isDesktop
2022-09-22 22:17:21 +00:00
? STextStyles.pageTitleH1(context)
: STextStyles.pageTitleH1(context).copyWith(
fontSize: 40,
2022-08-26 08:11:35 +00:00
),
);
}
}
2022-08-26 08:11:35 +00:00
class IntroAboutText extends StatelessWidget {
const IntroAboutText({Key? key, required this.isDesktop}) : super(key: key);
final bool isDesktop;
@override
Widget build(BuildContext context) {
return Text(
"An open-source, multicoin wallet for everyone",
textAlign: TextAlign.center,
style: !isDesktop
2022-09-22 22:17:21 +00:00
? STextStyles.subtitle(context)
: STextStyles.subtitle(context).copyWith(
fontSize: 24,
2022-08-26 08:11:35 +00:00
),
);
}
}
class PrivacyAndTOSText extends StatelessWidget {
const PrivacyAndTOSText({Key? key, required this.isDesktop})
: super(key: key);
final bool isDesktop;
@override
Widget build(BuildContext context) {
final fontSize = isDesktop ? 18.0 : 12.0;
return RichText(
textAlign: TextAlign.center,
text: TextSpan(
2022-09-22 22:17:21 +00:00
style: STextStyles.label(context).copyWith(fontSize: fontSize),
children: [
const TextSpan(text: "By using Stack Wallet, you agree to the "),
TextSpan(
text: "Terms of service",
2022-09-22 22:17:21 +00:00
style: STextStyles.richLink(context).copyWith(fontSize: fontSize),
recognizer: TapGestureRecognizer()
..onTap = () {
launchUrl(
Uri.parse("https://stackwallet.com/terms-of-service.html"),
mode: LaunchMode.externalApplication,
);
},
),
const TextSpan(text: " and "),
TextSpan(
text: "Privacy policy",
2022-09-22 22:17:21 +00:00
style: STextStyles.richLink(context).copyWith(fontSize: fontSize),
recognizer: TapGestureRecognizer()
..onTap = () {
launchUrl(
Uri.parse("https://stackwallet.com/privacy-policy.html"),
mode: LaunchMode.externalApplication,
);
},
),
],
2022-08-26 08:11:35 +00:00
),
);
}
}
class GetStartedButton extends StatelessWidget {
const GetStartedButton({Key? key, required this.isDesktop}) : super(key: key);
final bool isDesktop;
@override
Widget build(BuildContext context) {
return !isDesktop
? TextButton(
style: Theme.of(context)
.extension<StackColors>()!
2023-01-24 19:29:12 +00:00
.getPrimaryEnabledButtonStyle(context),
onPressed: () {
Prefs.instance.externalCalls = true;
Navigator.of(context).pushNamed(
StackPrivacyCalls.routeName,
arguments: false,
);
},
child: Text(
"Get started",
2022-09-22 22:17:21 +00:00
style: STextStyles.button(context),
),
)
: SizedBox(
width: double.infinity,
height: 70,
child: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
2023-01-24 19:29:12 +00:00
.getPrimaryEnabledButtonStyle(context),
onPressed: () {
Navigator.of(context).pushNamed(
StackPrivacyCalls.routeName,
arguments: false,
);
},
child: Text(
"Create new Stack",
2022-09-22 22:17:21 +00:00
style: STextStyles.button(context).copyWith(fontSize: 20),
),
),
);
}
}