2020-01-04 19:31:52 +00:00
|
|
|
import 'dart:convert';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
2020-09-28 15:47:43 +00:00
|
|
|
import 'package:cake_wallet/src/screens/faq/faq_item.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
2020-09-28 15:47:43 +00:00
|
|
|
import 'package:cake_wallet/src/widgets/standard_list.dart';
|
|
|
|
import 'package:cake_wallet/store/settings_store.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
class FaqPage extends BasePage {
|
2020-09-28 15:47:43 +00:00
|
|
|
FaqPage(this.settingsStore);
|
2020-01-04 19:31:52 +00:00
|
|
|
|
2020-09-28 15:47:43 +00:00
|
|
|
final SettingsStore settingsStore;
|
2020-05-22 16:15:06 +00:00
|
|
|
|
|
|
|
@override
|
2020-09-28 15:47:43 +00:00
|
|
|
String get title => S.current.faq;
|
2020-05-22 16:15:06 +00:00
|
|
|
|
2020-09-28 15:47:43 +00:00
|
|
|
String get path => 'assets/faq/faq_' + settingsStore.languageCode + '.json';
|
2020-05-22 16:15:06 +00:00
|
|
|
|
|
|
|
@override
|
2020-09-28 15:47:43 +00:00
|
|
|
Widget body(BuildContext context) {
|
2020-05-21 18:01:12 +00:00
|
|
|
return Container(
|
2020-09-07 17:35:34 +00:00
|
|
|
padding: EdgeInsets.only(top: 12, left: 24),
|
|
|
|
child: FutureBuilder(
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
final faqItems = jsonDecode(snapshot.data.toString()) as List;
|
2020-01-04 19:31:52 +00:00
|
|
|
|
2020-09-07 17:35:34 +00:00
|
|
|
return SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
StandardListSeparator(),
|
|
|
|
ListView.separated(
|
|
|
|
shrinkWrap: true,
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
2020-09-28 15:47:43 +00:00
|
|
|
final title = faqItems[index]["question"].toString();
|
|
|
|
final text = faqItems[index]["answer"].toString();
|
2020-01-04 19:31:52 +00:00
|
|
|
|
2020-09-28 15:47:43 +00:00
|
|
|
return FAQItem(title, text);
|
2020-09-07 17:35:34 +00:00
|
|
|
},
|
2020-09-28 15:47:43 +00:00
|
|
|
separatorBuilder: (_, __) => StandardListSeparator(),
|
|
|
|
itemCount: faqItems?.length ?? 0,
|
2020-09-07 17:35:34 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
2020-09-28 15:47:43 +00:00
|
|
|
future: rootBundle.loadString(path),
|
2020-05-21 18:01:12 +00:00
|
|
|
),
|
2020-01-04 19:31:52 +00:00
|
|
|
);
|
|
|
|
}
|
2020-09-28 15:47:43 +00:00
|
|
|
}
|