merge material 3
This commit is contained in:
@@ -1,140 +0,0 @@
|
||||
import 'package:fcs/domain/entities/faq.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/faq/faq_edit_page.dart';
|
||||
import 'package:fcs/pages/faq/model/faq_model.dart';
|
||||
import 'package:fcs/pages/main/model/language_model.dart';
|
||||
import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class FAQDetailPage extends StatefulWidget {
|
||||
final FAQ faq;
|
||||
const FAQDetailPage({required this.faq});
|
||||
@override
|
||||
_FAQDetailPageState createState() => _FAQDetailPageState();
|
||||
}
|
||||
|
||||
class _FAQDetailPageState extends State<FAQDetailPage> {
|
||||
bool _isLoading = false;
|
||||
FAQ faq = new FAQ();
|
||||
|
||||
intState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.faq.id != null)
|
||||
faq = context.select((FAQModel m) => m.getFAQ(widget.faq.id!));
|
||||
// if (faq == null) return Text("Deleted");
|
||||
|
||||
bool isEditable = context.select((MainModel m) => m.faqEditable());
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
body: CustomScrollView(slivers: [
|
||||
SliverAppBar(
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
CupertinoIcons.back,
|
||||
color: primaryColor,
|
||||
size: 50,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
expandedHeight: 100.0,
|
||||
floating: false,
|
||||
pinned: true,
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
centerTitle: true,
|
||||
titlePadding: EdgeInsets.symmetric(vertical: 10),
|
||||
),
|
||||
actions: isEditable
|
||||
? [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
showConfirmDialog(context, "faq.edit.delete.confirm",
|
||||
() {
|
||||
_delete();
|
||||
});
|
||||
},
|
||||
icon: Icon(
|
||||
CupertinoIcons.delete,
|
||||
color: primaryColor,
|
||||
size: 30,
|
||||
)),
|
||||
IconButton(
|
||||
onPressed: () =>
|
||||
Navigator.of(context).push<void>(CupertinoPageRoute(
|
||||
builder: (context) => FAQEditor(faq: faq),
|
||||
)),
|
||||
icon: Icon(
|
||||
CupertinoIcons.pen,
|
||||
color: primaryColor,
|
||||
))
|
||||
]
|
||||
: [],
|
||||
),
|
||||
SliverList(
|
||||
delegate: SliverChildListDelegate([
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(28.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
getQuestion(context, faq),
|
||||
SizedBox(
|
||||
height: 50,
|
||||
),
|
||||
getAnwser(context, faq)
|
||||
],
|
||||
),
|
||||
),
|
||||
]))
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getQuestion(BuildContext context, FAQ faq) {
|
||||
bool isEng = Provider.of<LanguageModel>(context).isEng;
|
||||
return TextLocalStyle(
|
||||
context,
|
||||
faq.question(isEng),
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
);
|
||||
}
|
||||
|
||||
Widget getAnwser(BuildContext context, FAQ faq) {
|
||||
bool isEng = Provider.of<LanguageModel>(context).isEng;
|
||||
return TextLocalStyle(
|
||||
context,
|
||||
faq.answer(isEng),
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w200,
|
||||
);
|
||||
}
|
||||
|
||||
_delete() async {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
try {
|
||||
FAQModel faqModel = Provider.of<FAQModel>(context, listen: false);
|
||||
await faqModel.deleteFAQ(faq);
|
||||
Navigator.pop(context);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
} finally {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,8 @@ import 'package:fcs/pages/faq/model/faq_model.dart';
|
||||
import 'package:fcs/pages/faq/widgets.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/input_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -84,6 +83,7 @@ class _FAQEditorState extends State<FAQEditor> {
|
||||
withBorder: true,
|
||||
);
|
||||
final pageLinkBox = DropdownButton<String>(
|
||||
isExpanded: true,
|
||||
value: _pageLink,
|
||||
style: TextStyle(color: Colors.deepPurple),
|
||||
underline: Container(
|
||||
@@ -124,33 +124,30 @@ class _FAQEditorState extends State<FAQEditor> {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||
onPressed: () {
|
||||
if (isDataChanged()) {
|
||||
showConfirmDialog(context, "back.button_confirm", () {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
appBar: LocalAppBar(
|
||||
labelKey: _isNew ? 'faq.add.title' : 'faq.edit.title',
|
||||
backgroundColor: Colors.white,
|
||||
shadowColor: Colors.transparent,
|
||||
title: LocalText(
|
||||
context, _isNew ? 'faq.add.title' : 'faq.edit.title',
|
||||
color: primaryColor, fontSize: 20),
|
||||
arrowColor: primaryColor,
|
||||
labelColor: primaryColor,
|
||||
onBack: () {
|
||||
if (isDataChanged()) {
|
||||
showConfirmDialog(context, "back.button_confirm", () {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.delete,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: _delete,
|
||||
)
|
||||
_isNew
|
||||
? const SizedBox()
|
||||
: IconButton(
|
||||
icon: Icon(
|
||||
Icons.delete,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: _delete,
|
||||
)
|
||||
],
|
||||
),
|
||||
body: Form(
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/payment_methods/payment_method_page.dart';
|
||||
import 'package:fcs/pages/rates/shipment_rates.dart';
|
||||
import 'package:fcs/pages/widgets/fcs_expansion_tile.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -15,7 +16,6 @@ import 'package:provider/provider.dart';
|
||||
|
||||
import 'model/faq_model.dart';
|
||||
|
||||
|
||||
class FAQListPage extends StatefulWidget {
|
||||
@override
|
||||
_FAQListPageState createState() => _FAQListPageState();
|
||||
@@ -29,19 +29,8 @@ class _FAQListPageState extends State<FAQListPage>
|
||||
bool isEditable = context.select((MainModel m) => m.faqEditable());
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: LocalText(
|
||||
context,
|
||||
"faq.title",
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
),
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
appBar: LocalAppBar(
|
||||
labelKey: "faq.title",
|
||||
actions: isEditable
|
||||
? [
|
||||
IconButton(
|
||||
|
||||
Reference in New Issue
Block a user