import 'package:checker/resources.dart'; import 'package:checker/strings.dart'; import 'package:flutter/material.dart'; import 'package:checker/base/base_state.dart'; import 'package:checker/consts.dart'; import 'package:checker/common.dart'; import 'package:checker/db.dart'; /// Класс содержит заголовки и текст блоков FAQ. class Entry { Entry(this.title, this.text); final String title; final String text; } class EntryItem extends StatelessWidget { const EntryItem(this.entry); final Entry entry; Widget _buildTiles(BuildContext context, Entry root) { EdgeInsets margin = new EdgeInsets.only(left: 20.0, right: 20.0); TextStyle titleStyle = Theme.of(context).textTheme.button.copyWith( fontWeight: FontWeight.bold, color: faqTitlesColor); return new Container(margin: margin, child: new Card( child: new ExpansionTile( key: new PageStorageKey(root), title:new Text( root.title, style: titleStyle), children: [ new Container( margin: margin, padding: new EdgeInsets.only(top: 12.0, bottom: 20.0), child: new Text( root.text, style: new TextStyle( fontWeight: FontWeight.w300, color: faqGrey, fontSize: 14.0) ), decoration: new BoxDecoration( border: new Border( top: new BorderSide( color: greyTextColor, width: 0.5) ) ) ) ] ) ) ); } @override Widget build(BuildContext context) { return _buildTiles(context, entry); } } class FAQScreen extends StatefulWidget { FAQScreen(this.b); final bool b; @override State createState() => new FAQScreenState(b); } class FAQScreenState extends BaseState { FAQScreenState(this.returnToScanner); bool returnToScanner; List data; @override String getTitle() { return StringsLocalization.help(); } @override String getHintString() { return null; } @override Widget build(BuildContext context) { if (app == null) { platform.invokeMethod('getFlavor').then((flavor) { setState(() { app = flavor; initPhoneAndUrl(); }); }); } return new Scaffold(appBar: getAppBar(), body: getScreenContent()); } void initPhoneAndUrl() { String phone, url; if (app == 'pip') { phone = '+38 080 030 9997\n+38 044 390 1697'; url = 'http://discount.kiev.ua/'; } else if (app == 'autobonus') { phone = '8-800-234-6064'; url = 'https://www.auto-club.biz'; } initHelp(phone, url); } void initHelp(String phone, String url) { data = [ new Entry(StringsLocalization.registration(), StringsLocalization.registrationGuide()), new Entry(StringsLocalization.usage(), StringsLocalization.usageGuide()), new Entry(StringsLocalization.support(), StringsLocalization.supportGuide(phone, url)), new Entry(StringsLocalization.common(), StringsLocalization.commonGuide()) ]; } @override List getMenuButtons() { return null; } /// Метод возвращает ListView с блоками faq. @override Widget getScreenContent() { if (data == null) { return new Container( decoration: new BoxDecoration( image: new DecorationImage( image: new ExactAssetImage(Resources.getSplash(app)), fit: BoxFit.cover))); } else { return new WillPopScope(onWillPop: onWillPop, child: new ListView.builder( itemBuilder: (BuildContext context, int index) => new EntryItem(data[index]), itemCount: data.length)); } } onWillPop() { if(returnToScanner) { return startScanner(context, app, helper); } else { return true; } } }