You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
3.1 KiB
Dart
90 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:tangheem/api/tangheem_user_api_client.dart';
|
|
import 'package:tangheem/app_state/app_state.dart';
|
|
import 'package:tangheem/classes/colors.dart';
|
|
import 'package:tangheem/classes/utils.dart';
|
|
import 'package:tangheem/extensions/int_extensions.dart';
|
|
import 'package:tangheem/extensions/string_extensions.dart';
|
|
import 'package:tangheem/extensions/widget_extensions.dart';
|
|
import 'package:tangheem/models/content_info_model.dart';
|
|
import 'package:tangheem/widgets/new/CommonHeader.dart';
|
|
|
|
class AboutScreen extends StatefulWidget {
|
|
AboutScreen({Key key}) : super(key: key);
|
|
|
|
@override
|
|
_AboutScreenState createState() {
|
|
return _AboutScreenState();
|
|
}
|
|
}
|
|
|
|
class _AboutScreenState extends State<AboutScreen> {
|
|
List<ContentInfoDataModel> haqooqAlMosasa;
|
|
List<ContentInfoDataModel> tareefAlMosasa;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
haqooqAlMosasa = AppState().haqooqAlMosasa;
|
|
tareefAlMosasa = AppState().tareefAlMosasa;
|
|
getContents();
|
|
}
|
|
|
|
void getContents() async {
|
|
Utils.showLoading(context);
|
|
try {
|
|
if ((haqooqAlMosasa ?? []).isEmpty || (tareefAlMosasa ?? []).isEmpty) {
|
|
List<ContentInfoModel> responseList = await Future.wait([TangheemUserApiClient().getContentInfo(2), if ((haqooqAlMosasa ?? []).isEmpty) TangheemUserApiClient().getContentInfo(1)]);
|
|
tareefAlMosasa = responseList[0].data ?? [];
|
|
AppState().tareefAlMosasa = tareefAlMosasa;
|
|
if ((haqooqAlMosasa ?? []).isEmpty) {
|
|
haqooqAlMosasa = responseList[1].data ?? [];
|
|
AppState().haqooqAlMosasa = haqooqAlMosasa;
|
|
}
|
|
} else {
|
|
await Future.delayed(Duration(milliseconds: 500));
|
|
}
|
|
} catch (ex) {
|
|
haqooqAlMosasa = [];
|
|
tareefAlMosasa = [];
|
|
if (mounted) Utils.handleException(ex, null);
|
|
} finally {
|
|
Utils.hideLoading(context);
|
|
}
|
|
setState(() {});
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
height: double.infinity,
|
|
child: SingleChildScrollView(
|
|
physics: const AlwaysScrollableScrollPhysics(),
|
|
child: Column(
|
|
children: [
|
|
CommonHeader("عن الموسوعة", "assets/icons/new/about_bg.jpg", Color(0xffAE8646)),
|
|
Column(
|
|
children: [
|
|
if ((tareefAlMosasa?.length ?? 0) > 0)
|
|
for (ContentInfoDataModel text in tareefAlMosasa) text.content.toText(13, color: ColorConsts.darkText, textAlign: TextAlign.center),
|
|
if ((haqooqAlMosasa?.length ?? 0) > 0)
|
|
Column(
|
|
children: [
|
|
"حقوق الموسوعة".toText(13, color: ColorConsts.greyLightColor),
|
|
for (ContentInfoDataModel text in haqooqAlMosasa) text.content.toText(13, color: ColorConsts.greyLightColor, textAlign: TextAlign.center)
|
|
],
|
|
).paddingOnly(top: 24)
|
|
],
|
|
).paddingOnly(top: 70, left: 35, right: 35, bottom: 125),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|