welcome: load terms from assets
This commit is contained in:
parent
4b3d5c389b
commit
fb4455399f
2 changed files with 35 additions and 23 deletions
|
@ -1,4 +1,3 @@
|
||||||
const String termsAndConditions = '''
|
|
||||||
# Terms of Service
|
# Terms of Service
|
||||||
Aves is an open-source gallery and metadata explorer app allowing you to access and manage your local photos.
|
Aves is an open-source gallery and metadata explorer app allowing you to access and manage your local photos.
|
||||||
|
|
||||||
|
@ -14,4 +13,4 @@ __We collect anonymous data to improve the app.__ We use Google Firebase for Ana
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
[Sources](https://github.com/deckerst/aves)
|
[Sources](https://github.com/deckerst/aves)
|
||||||
''';
|
[License](https://github.com/deckerst/aves/blob/master/LICENSE)
|
|
@ -1,10 +1,10 @@
|
||||||
import 'package:aves/model/settings.dart';
|
import 'package:aves/model/settings.dart';
|
||||||
import 'package:aves/model/terms.dart';
|
|
||||||
import 'package:aves/utils/durations.dart';
|
import 'package:aves/utils/durations.dart';
|
||||||
import 'package:aves/widgets/common/aves_logo.dart';
|
import 'package:aves/widgets/common/aves_logo.dart';
|
||||||
import 'package:aves/widgets/common/labeled_checkbox.dart';
|
import 'package:aves/widgets/common/labeled_checkbox.dart';
|
||||||
import 'package:aves/widgets/home_page.dart';
|
import 'package:aves/widgets/home_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||||
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
|
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
@ -18,6 +18,13 @@ class WelcomePage extends StatefulWidget {
|
||||||
|
|
||||||
class _WelcomePageState extends State<WelcomePage> {
|
class _WelcomePageState extends State<WelcomePage> {
|
||||||
bool _hasAcceptedTerms = false;
|
bool _hasAcceptedTerms = false;
|
||||||
|
Future<String> _termsLoader;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_termsLoader = rootBundle.loadString('assets/terms.md');
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -26,24 +33,30 @@ class _WelcomePageState extends State<WelcomePage> {
|
||||||
child: Container(
|
child: Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: FutureBuilder(
|
||||||
mainAxisSize: MainAxisSize.min,
|
future: _termsLoader,
|
||||||
children: _toStaggeredList(
|
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
|
||||||
duration: Durations.staggeredAnimation,
|
if (snapshot.hasError || snapshot.connectionState != ConnectionState.done) return const SizedBox.shrink();
|
||||||
delay: Durations.staggeredAnimationDelay,
|
final terms = snapshot.data;
|
||||||
childAnimationBuilder: (child) => SlideAnimation(
|
return Column(
|
||||||
verticalOffset: 50.0,
|
mainAxisSize: MainAxisSize.min,
|
||||||
child: FadeInAnimation(
|
children: _toStaggeredList(
|
||||||
child: child,
|
duration: Durations.staggeredAnimation,
|
||||||
),
|
delay: Durations.staggeredAnimationDelay,
|
||||||
),
|
childAnimationBuilder: (child) => SlideAnimation(
|
||||||
children: [
|
verticalOffset: 50.0,
|
||||||
..._buildTop(context),
|
child: FadeInAnimation(
|
||||||
Flexible(child: _buildTerms()),
|
child: child,
|
||||||
..._buildBottomControls(context),
|
),
|
||||||
],
|
),
|
||||||
),
|
children: [
|
||||||
),
|
..._buildTop(context),
|
||||||
|
Flexible(child: _buildTerms(terms)),
|
||||||
|
..._buildBottomControls(context),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -116,7 +129,7 @@ class _WelcomePageState extends State<WelcomePage> {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildTerms() {
|
Widget _buildTerms(String terms) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
@ -126,7 +139,7 @@ class _WelcomePageState extends State<WelcomePage> {
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
child: Markdown(
|
child: Markdown(
|
||||||
data: termsAndConditions,
|
data: terms,
|
||||||
// TODO TLAD make it selectable when this fix (in 1.18.0-6.0.pre) lands on stable: https://github.com/flutter/flutter/pull/54479
|
// TODO TLAD make it selectable when this fix (in 1.18.0-6.0.pre) lands on stable: https://github.com/flutter/flutter/pull/54479
|
||||||
selectable: false,
|
selectable: false,
|
||||||
onTapLink: (url) async {
|
onTapLink: (url) async {
|
||||||
|
|
Loading…
Reference in a new issue