2020-01-04 19:31:52 +00:00
|
|
|
import 'dart:convert';
|
2020-05-21 18:01:12 +00:00
|
|
|
import 'package:cake_wallet/palette.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
|
|
|
import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
|
|
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
|
|
|
|
|
|
|
class FaqPage extends BasePage {
|
2020-01-13 12:34:50 +00:00
|
|
|
@override
|
2020-01-04 19:31:52 +00:00
|
|
|
String get title => S.current.faq;
|
|
|
|
|
2020-05-21 18:01:12 +00:00
|
|
|
@override
|
|
|
|
Color get backgroundColor => PaletteDark.historyPanel;
|
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
@override
|
|
|
|
Widget body(BuildContext context) {
|
2020-05-21 18:01:12 +00:00
|
|
|
return Container(
|
|
|
|
color: PaletteDark.historyPanel,
|
|
|
|
padding: EdgeInsets.only(top: 12),
|
|
|
|
child: Container(
|
|
|
|
color: PaletteDark.menuList,
|
|
|
|
child: FutureBuilder(
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
final faqItems = jsonDecode(snapshot.data.toString()) as List;
|
2020-01-04 19:31:52 +00:00
|
|
|
|
2020-05-21 18:01:12 +00:00
|
|
|
return ListView.separated(
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
final itemTitle = faqItems[index]["question"].toString();
|
|
|
|
final itemChild = faqItems[index]["answer"].toString();
|
2020-01-04 19:31:52 +00:00
|
|
|
|
2020-05-21 18:01:12 +00:00
|
|
|
return ExpansionTile(
|
|
|
|
title: Padding(
|
|
|
|
padding: EdgeInsets.only(left: 8, top: 12, bottom: 12),
|
|
|
|
child: Text(itemTitle),
|
|
|
|
),
|
|
|
|
backgroundColor: PaletteDark.menuHeader,
|
2020-01-04 19:31:52 +00:00
|
|
|
children: <Widget>[
|
2020-05-21 18:01:12 +00:00
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.only(left: 24.0, right: 24.0, bottom: 4),
|
|
|
|
child: Text(
|
|
|
|
itemChild,
|
|
|
|
),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
)
|
2020-01-04 19:31:52 +00:00
|
|
|
],
|
2020-05-21 18:01:12 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
separatorBuilder: (_, __) =>
|
|
|
|
Divider(color: PaletteDark.mainBackgroundColor, height: 1.0),
|
|
|
|
itemCount: faqItems == null ? 0 : faqItems.length,
|
2020-01-04 19:31:52 +00:00
|
|
|
);
|
|
|
|
},
|
2020-05-21 18:01:12 +00:00
|
|
|
future: rootBundle.loadString(getFaqPath(context)),
|
|
|
|
),
|
|
|
|
),
|
2020-01-04 19:31:52 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
String getFaqPath(BuildContext context) {
|
|
|
|
final settingsStore = Provider.of<SettingsStore>(context);
|
|
|
|
|
|
|
|
switch (settingsStore.languageCode) {
|
|
|
|
case 'en':
|
|
|
|
return 'assets/faq/faq_en.json';
|
2020-02-21 14:37:57 +00:00
|
|
|
case 'uk':
|
|
|
|
return 'assets/faq/faq_uk.json';
|
2020-01-04 19:31:52 +00:00
|
|
|
case 'ru':
|
|
|
|
return 'assets/faq/faq_ru.json';
|
|
|
|
case 'es':
|
|
|
|
return 'assets/faq/faq_es.json';
|
|
|
|
case 'ja':
|
|
|
|
return 'assets/faq/faq_ja.json';
|
|
|
|
case 'ko':
|
|
|
|
return 'assets/faq/faq_ko.json';
|
|
|
|
case 'hi':
|
|
|
|
return 'assets/faq/faq_hi.json';
|
|
|
|
case 'de':
|
|
|
|
return 'assets/faq/faq_de.json';
|
|
|
|
case 'zh':
|
|
|
|
return 'assets/faq/faq_zh.json';
|
|
|
|
case 'pt':
|
|
|
|
return 'assets/faq/faq_pt.json';
|
|
|
|
case 'pl':
|
|
|
|
return 'assets/faq/faq_pl.json';
|
|
|
|
case 'nl':
|
|
|
|
return 'assets/faq/faq_nl.json';
|
|
|
|
default:
|
|
|
|
return 'assets/faq/faq_en.json';
|
|
|
|
}
|
|
|
|
}
|
2020-01-13 12:34:50 +00:00
|
|
|
}
|