2022-06-10 12:15:14 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
2021-03-31 07:45:12 +00:00
|
|
|
import 'package:dots_indicator/dots_indicator.dart';
|
2020-11-10 14:55:28 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:photos/core/configuration.dart';
|
2022-04-08 05:59:20 +00:00
|
|
|
import 'package:photos/ente_theme_data.dart';
|
2022-07-01 14:18:05 +00:00
|
|
|
import 'package:photos/ui/account/email_entry_page.dart';
|
|
|
|
import 'package:photos/ui/account/login_page.dart';
|
|
|
|
import 'package:photos/ui/account/password_entry_page.dart';
|
|
|
|
import 'package:photos/ui/account/password_reentry_page.dart';
|
2022-07-03 10:09:01 +00:00
|
|
|
import 'package:photos/ui/common/gradient_button.dart';
|
2021-08-21 08:47:34 +00:00
|
|
|
import 'package:photos/ui/payment/subscription.dart';
|
2020-11-10 14:55:28 +00:00
|
|
|
|
2021-05-29 17:01:59 +00:00
|
|
|
class LandingPageWidget extends StatefulWidget {
|
|
|
|
const LandingPageWidget({Key key}) : super(key: key);
|
2020-11-10 14:55:28 +00:00
|
|
|
|
|
|
|
@override
|
2022-07-03 09:45:00 +00:00
|
|
|
State<LandingPageWidget> createState() => _LandingPageWidgetState();
|
2020-11-10 14:55:28 +00:00
|
|
|
}
|
|
|
|
|
2021-05-29 17:01:59 +00:00
|
|
|
class _LandingPageWidgetState extends State<LandingPageWidget> {
|
2021-03-31 07:45:12 +00:00
|
|
|
double _featureIndex = 0;
|
2020-11-10 14:55:28 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-05-12 15:59:07 +00:00
|
|
|
return Scaffold(body: _getBody(), resizeToAvoidBottomInset: false);
|
2021-01-31 07:56:18 +00:00
|
|
|
}
|
|
|
|
|
2021-05-12 15:59:07 +00:00
|
|
|
Widget _getBody() {
|
2021-07-26 13:42:22 +00:00
|
|
|
return Center(
|
|
|
|
child: SingleChildScrollView(
|
2021-05-12 15:59:07 +00:00
|
|
|
child: Column(
|
|
|
|
children: [
|
2021-07-26 13:42:22 +00:00
|
|
|
Padding(padding: const EdgeInsets.all(12)),
|
2022-06-10 12:15:14 +00:00
|
|
|
Text(
|
|
|
|
"ente",
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontFamily: 'Montserrat',
|
2022-06-10 13:55:41 +00:00
|
|
|
fontSize: 42,
|
2021-05-12 15:59:07 +00:00
|
|
|
),
|
2021-03-31 07:45:12 +00:00
|
|
|
),
|
2021-05-12 15:59:07 +00:00
|
|
|
Padding(
|
2022-06-10 12:51:25 +00:00
|
|
|
padding: EdgeInsets.all(28),
|
2021-03-31 07:45:12 +00:00
|
|
|
),
|
2021-05-12 15:59:07 +00:00
|
|
|
_getFeatureSlider(),
|
2022-06-10 12:51:25 +00:00
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.all(12),
|
|
|
|
),
|
2021-07-26 13:42:22 +00:00
|
|
|
DotsIndicator(
|
2021-05-12 15:59:07 +00:00
|
|
|
dotsCount: 3,
|
|
|
|
position: _featureIndex,
|
|
|
|
decorator: DotsDecorator(
|
2022-07-03 09:49:33 +00:00
|
|
|
activeColor:
|
|
|
|
Theme.of(context).colorScheme.dotsIndicatorActiveColor,
|
2022-06-10 12:51:25 +00:00
|
|
|
color: Theme.of(context).colorScheme.dotsIndicatorInactiveColor,
|
|
|
|
activeShape: RoundedRectangleBorder(
|
2022-06-11 08:23:52 +00:00
|
|
|
borderRadius: BorderRadius.circular(3),
|
|
|
|
),
|
2022-06-10 12:51:25 +00:00
|
|
|
shape: RoundedRectangleBorder(
|
2022-06-11 08:23:52 +00:00
|
|
|
borderRadius: BorderRadius.circular(3),
|
|
|
|
),
|
2022-06-10 12:51:25 +00:00
|
|
|
size: Size(100, 5),
|
|
|
|
activeSize: Size(100, 5),
|
|
|
|
spacing: EdgeInsets.all(3),
|
2021-05-12 15:59:07 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
Padding(
|
2021-03-31 07:45:12 +00:00
|
|
|
padding: EdgeInsets.all(28),
|
2021-05-12 15:59:07 +00:00
|
|
|
),
|
|
|
|
_getSignUpButton(context),
|
2022-04-06 20:32:41 +00:00
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
2022-04-21 09:43:22 +00:00
|
|
|
padding: EdgeInsets.fromLTRB(20, 12, 20, 28),
|
2022-04-06 20:32:41 +00:00
|
|
|
child: Hero(
|
|
|
|
tag: "log_in",
|
|
|
|
child: ElevatedButton(
|
2022-07-03 09:49:33 +00:00
|
|
|
style:
|
|
|
|
Theme.of(context).colorScheme.optionalActionButtonStyle,
|
2022-07-03 09:45:00 +00:00
|
|
|
onPressed: _navigateToSignInPage,
|
2022-04-06 20:32:41 +00:00
|
|
|
child: Text(
|
2022-05-30 14:13:19 +00:00
|
|
|
"Existing user",
|
2022-06-10 12:04:14 +00:00
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.black, // same for both themes
|
|
|
|
),
|
2021-01-03 06:44:44 +00:00
|
|
|
),
|
2021-03-31 07:45:12 +00:00
|
|
|
),
|
2021-01-03 06:44:44 +00:00
|
|
|
),
|
|
|
|
),
|
2021-05-12 15:59:07 +00:00
|
|
|
Padding(
|
2021-07-26 13:42:22 +00:00
|
|
|
padding: EdgeInsets.all(20),
|
2021-05-12 15:59:07 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2021-03-31 07:45:12 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-07-26 13:42:22 +00:00
|
|
|
Widget _getSignUpButton(BuildContext context) {
|
2022-04-06 20:32:41 +00:00
|
|
|
return Container(
|
|
|
|
width: double.infinity,
|
2022-04-21 05:12:18 +00:00
|
|
|
padding: EdgeInsets.symmetric(horizontal: 20),
|
|
|
|
child: GradientButton(
|
|
|
|
onTap: _navigateToSignUpPage,
|
2022-07-04 04:45:32 +00:00
|
|
|
text: "New to ente",
|
2021-03-31 07:45:12 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-05-12 06:05:57 +00:00
|
|
|
Widget _getFeatureSlider() {
|
2021-05-12 15:59:07 +00:00
|
|
|
return ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(maxHeight: 320),
|
2021-03-31 07:45:12 +00:00
|
|
|
child: PageView(
|
2022-06-10 12:15:14 +00:00
|
|
|
children: [
|
|
|
|
FeatureItemWidget(
|
2022-06-24 15:29:24 +00:00
|
|
|
"assets/onboarding_lock.png",
|
2022-06-10 12:15:14 +00:00
|
|
|
"Private backups",
|
|
|
|
"for your memories",
|
2022-06-11 03:33:09 +00:00
|
|
|
"End-to-end encrypted by default",
|
2022-06-10 12:15:14 +00:00
|
|
|
),
|
2021-05-13 20:59:09 +00:00
|
|
|
FeatureItemWidget(
|
2022-06-24 15:29:24 +00:00
|
|
|
"assets/onboarding_safe.png",
|
2022-06-10 12:15:14 +00:00
|
|
|
"Safely stored",
|
|
|
|
"at a fallout shelter",
|
2022-06-11 03:33:09 +00:00
|
|
|
"Designed to outlive",
|
2022-06-10 12:15:14 +00:00
|
|
|
),
|
2021-05-13 20:59:09 +00:00
|
|
|
FeatureItemWidget(
|
2022-06-24 15:29:24 +00:00
|
|
|
"assets/onboarding_lock.png",
|
2022-06-10 12:15:14 +00:00
|
|
|
"Available",
|
|
|
|
"everywhere",
|
2022-07-03 09:49:33 +00:00
|
|
|
Platform.isAndroid
|
|
|
|
? "Android, iOS, Web, Desktop"
|
|
|
|
: "iOS, Android, Web, Desktop",
|
2022-06-10 12:15:14 +00:00
|
|
|
),
|
2021-03-31 07:45:12 +00:00
|
|
|
],
|
|
|
|
onPageChanged: (index) {
|
|
|
|
setState(() {
|
|
|
|
_featureIndex = double.parse(index.toString());
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-04-01 17:50:19 +00:00
|
|
|
void _navigateToSignUpPage() {
|
2021-07-26 13:42:22 +00:00
|
|
|
Widget page;
|
2021-06-12 09:44:00 +00:00
|
|
|
if (Configuration.instance.getEncryptedToken() == null) {
|
2021-04-01 17:50:19 +00:00
|
|
|
page = EmailEntryPage();
|
|
|
|
} else {
|
|
|
|
// No key
|
|
|
|
if (Configuration.instance.getKeyAttributes() == null) {
|
|
|
|
// Never had a key
|
|
|
|
page = PasswordEntryPage();
|
|
|
|
} else if (Configuration.instance.getKey() == null) {
|
|
|
|
// Yet to decrypt the key
|
|
|
|
page = PasswordReentryPage();
|
|
|
|
} else {
|
|
|
|
// All is well, user just has not subscribed
|
2021-08-21 08:47:34 +00:00
|
|
|
page = getSubscriptionPage(isOnBoarding: true);
|
2021-04-01 17:50:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return page;
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _navigateToSignInPage() {
|
2021-07-26 13:42:22 +00:00
|
|
|
Widget page;
|
2021-06-12 09:44:00 +00:00
|
|
|
if (Configuration.instance.getEncryptedToken() == null) {
|
2021-04-01 17:50:19 +00:00
|
|
|
page = LoginPage();
|
|
|
|
} else {
|
|
|
|
// No key
|
|
|
|
if (Configuration.instance.getKeyAttributes() == null) {
|
|
|
|
// Never had a key
|
|
|
|
page = PasswordEntryPage();
|
|
|
|
} else if (Configuration.instance.getKey() == null) {
|
|
|
|
// Yet to decrypt the key
|
|
|
|
page = PasswordReentryPage();
|
|
|
|
} else {
|
|
|
|
// All is well, user just has not subscribed
|
2021-08-21 08:47:34 +00:00
|
|
|
page = getSubscriptionPage(isOnBoarding: true);
|
2021-04-01 17:50:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return page;
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2020-11-10 14:55:28 +00:00
|
|
|
}
|
2021-05-13 20:59:09 +00:00
|
|
|
|
|
|
|
class FeatureItemWidget extends StatelessWidget {
|
2022-07-03 09:49:33 +00:00
|
|
|
final String assetPath,
|
|
|
|
featureTitleFirstLine,
|
|
|
|
featureTitleSecondLine,
|
|
|
|
subText;
|
2022-06-10 12:15:14 +00:00
|
|
|
|
2021-05-13 20:59:09 +00:00
|
|
|
const FeatureItemWidget(
|
|
|
|
this.assetPath,
|
2022-06-10 12:15:14 +00:00
|
|
|
this.featureTitleFirstLine,
|
|
|
|
this.featureTitleSecondLine,
|
|
|
|
this.subText, {
|
2021-05-13 20:59:09 +00:00
|
|
|
Key key,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-07-26 13:42:22 +00:00
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
Image.asset(
|
|
|
|
assetPath,
|
|
|
|
height: 160,
|
|
|
|
),
|
|
|
|
Padding(padding: EdgeInsets.all(16)),
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
2022-06-10 12:15:14 +00:00
|
|
|
featureTitleFirstLine,
|
|
|
|
style: Theme.of(context).textTheme.headline5,
|
2021-05-13 20:59:09 +00:00
|
|
|
),
|
2022-06-10 12:15:14 +00:00
|
|
|
Padding(padding: EdgeInsets.all(2)),
|
2021-07-26 13:42:22 +00:00
|
|
|
Text(
|
2022-06-10 12:15:14 +00:00
|
|
|
featureTitleSecondLine,
|
|
|
|
style: Theme.of(context).textTheme.headline5,
|
2021-07-26 13:42:22 +00:00
|
|
|
),
|
2022-06-10 12:15:14 +00:00
|
|
|
Padding(padding: EdgeInsets.all(12)),
|
2021-07-26 13:42:22 +00:00
|
|
|
Text(
|
2022-06-10 12:15:14 +00:00
|
|
|
subText,
|
2021-07-26 13:42:22 +00:00
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
2022-06-10 12:15:14 +00:00
|
|
|
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
|
|
|
|
fontSize: 16,
|
2021-07-26 13:42:22 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2021-05-13 20:59:09 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|