|
| 1 | +import 'package:flutter/cupertino.dart'; |
| 2 | +import 'package:flutter/widgets.dart'; |
| 3 | +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; |
| 4 | +import 'package:url_launcher/url_launcher.dart'; |
| 5 | +import 'package:who_app/components/page_button.dart'; |
| 6 | +import 'package:who_app/components/page_scaffold/page_header.dart'; |
| 7 | +import 'package:who_app/components/page_scaffold/page_scaffold.dart'; |
| 8 | +import 'package:who_app/components/themed_text.dart'; |
| 9 | +import 'package:who_app/constants.dart'; |
| 10 | + |
| 11 | +class CheckUpIntroPage extends StatelessWidget { |
| 12 | + @override |
| 13 | + Widget build(BuildContext context) { |
| 14 | + return PageScaffold( |
| 15 | + disableBackButton: true, |
| 16 | + headingBorderColor: Color(0x0), |
| 17 | + color: CupertinoColors.white, |
| 18 | + // TODO: localize |
| 19 | + title: "Check-Up", |
| 20 | + header: SliverSafeArea( |
| 21 | + top: true, |
| 22 | + bottom: false, |
| 23 | + sliver: SliverToBoxAdapter( |
| 24 | + child: Padding( |
| 25 | + padding: EdgeInsets.fromLTRB(16, 36, 16, 20), |
| 26 | + // TODO: localize |
| 27 | + child: PageHeader.buildTitle("Check-Up", |
| 28 | + textStyle: ThemedText.styleForVariant( |
| 29 | + TypographyVariant.title) |
| 30 | + .merge( |
| 31 | + TextStyle(color: Constants.primaryDarkColor)))))), |
| 32 | + body: <Widget>[_buildBody(context)], |
| 33 | + ); |
| 34 | + } |
| 35 | + |
| 36 | + Widget _buildBody(BuildContext context) => SliverList( |
| 37 | + delegate: SliverChildListDelegate([ |
| 38 | + ...optionWidgets(), |
| 39 | + submitWidget(context), |
| 40 | + ])); |
| 41 | + |
| 42 | + List<Widget> optionWidgets() { |
| 43 | + // TODO: localize everything |
| 44 | + return <Widget>[ |
| 45 | + Padding( |
| 46 | + padding: const EdgeInsets.only( |
| 47 | + left: 24, |
| 48 | + right: 60, |
| 49 | + bottom: 20, |
| 50 | + top: 0, |
| 51 | + ), |
| 52 | + child: ThemedText( |
| 53 | + "You should know...", |
| 54 | + variant: TypographyVariant.body, |
| 55 | + style: TextStyle(fontWeight: FontWeight.bold), |
| 56 | + )), |
| 57 | + _ListItem( |
| 58 | + title: |
| 59 | + "Your answers will not be shared with WHO or others without your permission.", |
| 60 | + icon: FontAwesomeIcons.lock), |
| 61 | + _ListItem( |
| 62 | + title: |
| 63 | + "By using this tool, you agree to its terms and that WHO will not be liable for any harm relating to your use.", |
| 64 | + icon: FontAwesomeIcons.solidCheckCircle, |
| 65 | + ), |
| 66 | + _ListItem( |
| 67 | + title: |
| 68 | + "Information provided by this tool does not constitute medical advise and should not be used to diagnose or treat medical conditions.", |
| 69 | + icon: FontAwesomeIcons.fileMedical, |
| 70 | + extra: CupertinoButton( |
| 71 | + padding: EdgeInsets.zero, |
| 72 | + child: ThemedText( |
| 73 | + "See terms ›", |
| 74 | + variant: TypographyVariant.body, |
| 75 | + style: TextStyle( |
| 76 | + color: Constants.whoBackgroundBlueColor, |
| 77 | + ), |
| 78 | + ), |
| 79 | + onPressed: () { |
| 80 | + return launch("https://whoapp.org/terms"); |
| 81 | + }, |
| 82 | + ), |
| 83 | + ), |
| 84 | + ]; |
| 85 | + } |
| 86 | + |
| 87 | + Widget submitWidget(BuildContext context) { |
| 88 | + return Padding( |
| 89 | + padding: const EdgeInsets.only( |
| 90 | + top: 52, |
| 91 | + left: 24, |
| 92 | + right: 24, |
| 93 | + bottom: 48, |
| 94 | + ), |
| 95 | + child: PageButton( |
| 96 | + Constants.whoBackgroundBlueColor, |
| 97 | + "Get Started", |
| 98 | + () => Navigator.of(context, rootNavigator: true) |
| 99 | + .pushNamed('/symptom-checker-survey'), |
| 100 | + crossAxisAlignment: CrossAxisAlignment.center, |
| 101 | + mainAxisAlignment: MainAxisAlignment.center, |
| 102 | + verticalPadding: 12, |
| 103 | + borderRadius: 500, |
| 104 | + titleStyle: ThemedText.styleForVariant(TypographyVariant.button) |
| 105 | + .merge(TextStyle(color: CupertinoColors.white)), |
| 106 | + ), |
| 107 | + ); |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +class _ListItem extends StatelessWidget { |
| 112 | + final String title; |
| 113 | + final String subtitle; |
| 114 | + final IconData icon; |
| 115 | + final Widget extra; |
| 116 | + |
| 117 | + _ListItem( |
| 118 | + {@required this.title, @required this.icon, this.subtitle, this.extra}); |
| 119 | + |
| 120 | + @override |
| 121 | + Widget build(BuildContext context) { |
| 122 | + return Padding( |
| 123 | + padding: const EdgeInsets.only( |
| 124 | + left: 32, |
| 125 | + right: 60, |
| 126 | + bottom: 20, |
| 127 | + ), |
| 128 | + child: Row( |
| 129 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 130 | + children: <Widget>[ |
| 131 | + Icon( |
| 132 | + icon, |
| 133 | + color: Constants.whoBackgroundBlueColor, |
| 134 | + size: 24, |
| 135 | + ), |
| 136 | + SizedBox( |
| 137 | + width: 12, |
| 138 | + ), |
| 139 | + Flexible( |
| 140 | + child: Column( |
| 141 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 142 | + children: <Widget>[ |
| 143 | + ThemedText(this.title, variant: TypographyVariant.body), |
| 144 | + if (extra != null) extra, |
| 145 | + ])) |
| 146 | + ], |
| 147 | + ), |
| 148 | + ); |
| 149 | + } |
| 150 | +} |
0 commit comments