ente/lib/ui/landing_page_widget.dart

311 lines
8.9 KiB
Dart
Raw Normal View History

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:flutter/widgets.dart';
import 'package:photos/core/configuration.dart';
import 'package:photos/ui/email_entry_page.dart';
2021-03-30 11:08:41 +00:00
import 'package:photos/ui/login_page.dart';
2021-01-05 14:27:02 +00:00
import 'package:photos/ui/password_entry_page.dart';
import 'package:photos/ui/password_reentry_page.dart';
2021-01-06 16:09:42 +00:00
import 'package:photos/ui/subscription_page.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
2021-05-29 17:01:59 +00:00
_LandingPageWidgetState 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-05-12 15:59:07 +00:00
Widget _getBody() {
return SingleChildScrollView(
child: Container(
padding: EdgeInsets.fromLTRB(8, 40, 8, 8),
child: Column(
children: [
Text.rich(
TextSpan(
children: <TextSpan>[
TextSpan(
text: "with ",
style: TextStyle(
fontSize: 16,
),
),
2021-05-12 15:59:07 +00:00
TextSpan(
text: "ente",
style: TextStyle(
fontWeight: FontWeight.bold,
fontFamily: 'Montserrat',
fontSize: 16,
),
2021-03-31 07:45:12 +00:00
),
2021-05-12 15:59:07 +00:00
],
),
textAlign: TextAlign.center,
2021-03-31 07:45:12 +00:00
),
2021-05-12 15:59:07 +00:00
Padding(
padding: EdgeInsets.all(2),
),
Text.rich(
TextSpan(
children: <TextSpan>[
TextSpan(
text: "your ",
style: TextStyle(
fontSize: 16,
),
2021-03-31 07:45:12 +00:00
),
2021-05-12 15:59:07 +00:00
TextSpan(
text: "memories",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
),
2021-03-31 07:45:12 +00:00
),
2021-05-12 15:59:07 +00:00
TextSpan(
text: " are",
style: TextStyle(
fontSize: 16,
),
),
2021-05-12 15:59:07 +00:00
],
),
textAlign: TextAlign.center,
2021-03-31 07:45:12 +00:00
),
2021-05-12 15:59:07 +00:00
Padding(
padding: EdgeInsets.all(24),
2021-03-31 07:45:12 +00:00
),
2021-05-12 15:59:07 +00:00
_getFeatureSlider(),
new DotsIndicator(
dotsCount: 3,
position: _featureIndex,
decorator: DotsDecorator(
color: Colors.white24, // Inactive color
activeColor: Theme.of(context).buttonColor,
),
),
Padding(
2021-03-31 07:45:12 +00:00
padding: EdgeInsets.all(28),
2021-05-12 15:59:07 +00:00
),
_getSignUpButton(context),
Padding(
padding: EdgeInsets.all(4),
),
GestureDetector(
behavior: HitTestBehavior.translucent,
child: Container(
width: double.infinity,
padding: EdgeInsets.all(28),
child: Center(
child: Hero(
tag: "log_in",
2021-05-12 15:59:07 +00:00
child: Material(
type: MaterialType.transparency,
child: Text(
"log in",
2021-05-12 15:59:07 +00:00
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
letterSpacing: 0.6,
2021-07-05 08:32:01 +00:00
color: Colors.white.withOpacity(0.95),
2021-05-12 15:59:07 +00:00
),
2021-05-12 10:03:59 +00:00
),
),
),
2021-03-31 07:45:12 +00:00
),
),
2021-05-12 15:59:07 +00:00
onTap: _navigateToSignInPage,
),
2021-05-12 15:59:07 +00:00
Padding(
padding: EdgeInsets.all(4),
),
],
),
2021-03-31 07:45:12 +00:00
),
);
}
Container _getSignUpButton(BuildContext context) {
return Container(
2021-07-10 07:40:59 +00:00
width: 200,
2021-05-12 05:24:34 +00:00
height: 64,
child: OutlinedButton(
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
padding: EdgeInsets.fromLTRB(50, 16, 50, 16),
side: BorderSide(
width: 2,
2021-05-12 15:59:07 +00:00
color: Theme.of(context).buttonColor,
2021-03-31 07:45:12 +00:00
),
),
2021-05-12 05:24:34 +00:00
child: Hero(
tag: "sign_up",
child: Material(
type: MaterialType.transparency,
child: Text(
"sign up",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
2021-05-12 06:05:57 +00:00
letterSpacing: 0.6,
2021-05-12 05:24:34 +00:00
),
),
),
2021-03-31 07:45:12 +00:00
),
2021-05-12 05:24:34 +00:00
onPressed: _navigateToSignUpPage,
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(
children: [
2021-05-13 20:59:09 +00:00
FeatureItemWidget(
"assets/protected.png",
"protected",
"end-to-end encrypted with your password,",
"visible only to you"),
FeatureItemWidget("assets/synced.png", "synced",
"available across all your devices,", "web, android and ios"),
FeatureItemWidget(
"assets/preserved.png",
"preserved",
"reliably replicated to a fallout shelter,",
"designed to outlive"),
2021-03-31 07:45:12 +00:00
],
onPageChanged: (index) {
setState(() {
_featureIndex = double.parse(index.toString());
});
},
),
);
}
void _navigateToSignUpPage() {
var page;
if (Configuration.instance.getEncryptedToken() == null) {
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
page = SubscriptionPage(isOnboarding: true);
}
}
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) {
return page;
},
),
);
}
void _navigateToSignInPage() {
var page;
if (Configuration.instance.getEncryptedToken() == null) {
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
page = SubscriptionPage(isOnboarding: true);
}
}
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 {
final String assetPath, featureTitle, firstLine, secondLine;
const FeatureItemWidget(
this.assetPath,
this.featureTitle,
this.firstLine,
this.secondLine, {
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Image.asset(
assetPath,
2021-05-16 09:46:35 +00:00
height: 160,
2021-05-13 20:59:09 +00:00
),
Padding(padding: EdgeInsets.all(16)),
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
featureTitle,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Theme.of(context).buttonColor,
),
),
Padding(padding: EdgeInsets.all(12)),
Container(
child: Text(
firstLine,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white.withOpacity(0.9),
),
),
),
Padding(padding: EdgeInsets.all(2)),
Container(
child: Text(
secondLine,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white.withOpacity(0.9),
),
),
),
],
),
),
],
),
);
}
}