Bug Fixes
parent
3d9099d9e7
commit
0bbc288da9
@ -0,0 +1,127 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mc_common_app/config/routes.dart';
|
||||||
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:mc_common_app/models/chat_models/chat_message_model.dart';
|
||||||
|
import 'package:mc_common_app/models/setting_utils_models/app_info_model.dart';
|
||||||
|
import 'package:mc_common_app/theme/colors.dart';
|
||||||
|
import 'package:mc_common_app/utils/enums.dart';
|
||||||
|
import 'package:mc_common_app/utils/navigator.dart';
|
||||||
|
import 'package:mc_common_app/view_models/setting_options_view_model.dart';
|
||||||
|
import 'package:mc_common_app/views/advertisement/components/picked_images_container_widget.dart';
|
||||||
|
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
|
||||||
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class SettingOptionsTermsAndConditions extends StatefulWidget {
|
||||||
|
const SettingOptionsTermsAndConditions({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SettingOptionsTermsAndConditions> createState() => _SettingOptionsTermsAndConditionsState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SettingOptionsTermsAndConditionsState extends State<SettingOptionsTermsAndConditions> {
|
||||||
|
late SettingOptionsVM settingsOptionsVM;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
settingsOptionsVM = context.read<SettingOptionsVM>();
|
||||||
|
scheduleMicrotask(() async {
|
||||||
|
await settingsOptionsVM.getTermsAndConditions();
|
||||||
|
});
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget showData(String title, String value) {
|
||||||
|
return Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
title.toText(
|
||||||
|
fontSize: 13,
|
||||||
|
color: MyColors.darkTextColor,
|
||||||
|
),
|
||||||
|
if (title.isNotEmpty) 5.width,
|
||||||
|
Flexible(
|
||||||
|
child: value.toText(
|
||||||
|
fontSize: 13,
|
||||||
|
color: MyColors.lightTextColor,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: CustomAppBar(
|
||||||
|
title: LocaleKeys.termPrivacy.tr(),
|
||||||
|
isRemoveBackButton: false,
|
||||||
|
isDrawerEnabled: false,
|
||||||
|
onBackButtonTapped: () => Navigator.pop(context),
|
||||||
|
),
|
||||||
|
body: Consumer(
|
||||||
|
builder: (BuildContext context, SettingOptionsVM settingsOptionsVM, Widget? child) {
|
||||||
|
return Container(
|
||||||
|
color: MyColors.backgroundColor,
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
16.height,
|
||||||
|
Expanded(
|
||||||
|
child: RefreshIndicator(
|
||||||
|
onRefresh: () async => await settingsOptionsVM.getTermsAndConditions(),
|
||||||
|
child: (settingsOptionsVM.state == ViewState.busy)
|
||||||
|
? const Center(child: CircularProgressIndicator())
|
||||||
|
: settingsOptionsVM.termsAndConditionsList.isEmpty
|
||||||
|
? Padding(
|
||||||
|
padding: const EdgeInsets.all(21),
|
||||||
|
child: Center(child: LocaleKeys.somethingWrong.tr().toText(textAlign: TextAlign.center, fontSize: 16, color: MyColors.lightTextColor)),
|
||||||
|
)
|
||||||
|
: ListView.separated(
|
||||||
|
itemCount: settingsOptionsVM.termsAndConditionsList.length,
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
AppInfoModel appInfoModel = settingsOptionsVM.termsAndConditionsList[index];
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
(appInfoModel.header ?? "").toString().toText(fontSize: 16),
|
||||||
|
5.height,
|
||||||
|
(appInfoModel.content ?? "").toString().toText(fontSize: 14, color: MyColors.lightTextColor),
|
||||||
|
if (appInfoModel.images != null && appInfoModel.images!.isNotEmpty) ...[
|
||||||
|
PickedFilesContainer(
|
||||||
|
pickedFiles: appInfoModel.images ?? [],
|
||||||
|
isReview: true,
|
||||||
|
onAddFilePressed: () {},
|
||||||
|
).onPress(() {
|
||||||
|
List<MessageImageModel> images = [];
|
||||||
|
for (var image in appInfoModel.images!) {
|
||||||
|
images.add(MessageImageModel(
|
||||||
|
id: image.id,
|
||||||
|
isFromNetwork: true,
|
||||||
|
imageUrl: image.filePath,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
navigateWithName(context, AppRoutes.mediaViewerScreen, arguments: images);
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
],
|
||||||
|
).toContainer(isShadowEnabled: true);
|
||||||
|
},
|
||||||
|
separatorBuilder: (context, index) => 16.height,
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue