demo module ui cont.
parent
5faa87c1b9
commit
a103eae1c1
@ -0,0 +1,107 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/string_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/views/widgets/images/files_list.dart';
|
||||
|
||||
import '../../controllers/api_routes/urls.dart';
|
||||
import '../../extensions/text_extensions.dart';
|
||||
import '../../new_views/app_style/app_color.dart';
|
||||
import '../../new_views/common_widgets/app_filled_button.dart';
|
||||
import '../../new_views/common_widgets/default_app_bar.dart';
|
||||
import '../cm_module/views/components/action_button/footer_action_button.dart';
|
||||
import 'demo_extension_bottom_sheet.dart';
|
||||
|
||||
class DemoActivitiesPage extends StatelessWidget {
|
||||
DemoActivitiesPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: const DefaultAppBar(title: "Activities"),
|
||||
body: FutureBuilder<void>(
|
||||
future: Future.delayed(Duration(seconds: 1)),
|
||||
builder: (BuildContext context, AsyncSnapshot<void> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) return const CircularProgressIndicator(color: AppColor.primary10).center;
|
||||
List<String> allAttachments = [];
|
||||
return Column(
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Installation Date',
|
||||
style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120),
|
||||
),
|
||||
Text(
|
||||
'03 Mar, 2025',
|
||||
style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral50),
|
||||
),
|
||||
12.height,
|
||||
Text(
|
||||
"End-user signature",
|
||||
style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120),
|
||||
),
|
||||
12.height,
|
||||
if (allAttachments.isNotEmpty) ...[
|
||||
const Divider().defaultStyle(context),
|
||||
Text(
|
||||
"Attachments".addTranslation,
|
||||
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||
),
|
||||
FilesList(images: allAttachments.map((e) => URLs.getFileUrl(e ?? '') ?? '').toList() ?? []),
|
||||
],
|
||||
],
|
||||
).toShadowContainer(context, borderRadius: 14, backgroundColor: Color(0xffF4F8FC), showShadow: false),
|
||||
16.height,
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Estimation Delivery Date',
|
||||
style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120),
|
||||
),
|
||||
Text(
|
||||
'03 Mar, 2025',
|
||||
style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral50),
|
||||
),
|
||||
],
|
||||
).toShadowContainer(context, borderRadius: 14, backgroundColor: Color(0xffF4F8FC), showShadow: false),
|
||||
],
|
||||
).toShadowContainer(
|
||||
context,
|
||||
borderRadius: 20,
|
||||
showShadow: false,
|
||||
)).expanded,
|
||||
FooterActionButton.footerContainer(
|
||||
context: context,
|
||||
child: AppFilledButton(
|
||||
buttonColor: AppColor.primary10,
|
||||
label: "Extension Request",
|
||||
onPressed: () => _extensionRequest(context),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
void _extensionRequest(context) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
useSafeArea: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (context) => const DemoExtensionBottomSheet(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,188 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/string_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
||||
import 'package:test_sa/modules/demo_module/demo_extension_bottom_sheet.dart';
|
||||
import 'package:test_sa/modules/demo_module/demo_provider.dart';
|
||||
import 'package:test_sa/modules/loan_module/models/loan_attachment_model.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
||||
|
||||
import '../../controllers/api_routes/urls.dart';
|
||||
import '../../extensions/text_extensions.dart';
|
||||
import '../../new_views/common_widgets/default_app_bar.dart';
|
||||
import '../../views/widgets/images/files_list.dart';
|
||||
import '../../views/widgets/requests/request_status.dart';
|
||||
import '../loan_module/models/loan_request_model.dart';
|
||||
import 'demo_activities_page.dart';
|
||||
|
||||
class DemoDetailViewPage extends StatefulWidget {
|
||||
static const String id = "/demo-detail-page";
|
||||
final int demoId;
|
||||
|
||||
DemoDetailViewPage({Key? key, required this.demoId}) : super(key: key);
|
||||
|
||||
@override
|
||||
_DemoDetailViewPageState createState() {
|
||||
return _DemoDetailViewPageState();
|
||||
}
|
||||
}
|
||||
|
||||
class _DemoDetailViewPageState extends State<DemoDetailViewPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
List<LoanAttachmentModel> allAttachments = [];
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: const DefaultAppBar(title: "Request Details"),
|
||||
body: Column(
|
||||
children: [
|
||||
// FutureBuilder<LoanRequestModel?>(
|
||||
// future: Provider.of<DemoProvider>(context, listen: false).getLoanById(widget.demoId),
|
||||
// builder: (BuildContext context, AsyncSnapshot<LoanRequestModel?> snapshot) {
|
||||
// if (snapshot.connectionState == ConnectionState.waiting) return const CircularProgressIndicator(color: AppColor.primary10).center;
|
||||
// if (snapshot.data == null) return const NoDataFound().center;
|
||||
//
|
||||
// List<LoanAttachmentModel> allAttachments = snapshot.data!.loanAttachments!;
|
||||
//
|
||||
// return
|
||||
|
||||
SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// StatusLabel(
|
||||
// label: snapshot.data!.loanStatusName!,
|
||||
// textColor: AppColor.getRequestStatusTextColorByName(context, snapshot.data!.loanStatusName!),
|
||||
// backgroundColor: AppColor.getRequestStatusColorByName(context, snapshot.data!.loanStatusName!),
|
||||
// ),
|
||||
// 1.width.expanded,
|
||||
// Text(
|
||||
// snapshot.data!.createdDate?.toServiceRequestCardFormat ?? "-",
|
||||
// textAlign: TextAlign.end,
|
||||
// style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// 12.height,
|
||||
...requesterDetails(context, LoanRequestModel()),
|
||||
12.height,
|
||||
...requestDetails(context, LoanRequestModel()),
|
||||
12.height,
|
||||
...doctorDetails(context, LoanRequestModel()),
|
||||
12.height,
|
||||
...assetDetails(context, LoanRequestModel()),
|
||||
12.height,
|
||||
...vendorDetails(context, LoanRequestModel()),
|
||||
if (allAttachments.isNotEmpty) ...[
|
||||
const Divider().defaultStyle(context),
|
||||
Text(
|
||||
"Attachments".addTranslation,
|
||||
style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||
),
|
||||
FilesList(images: allAttachments.map((e) => URLs.getFileUrl(e.attachmentName ?? '') ?? '').toList() ?? []),
|
||||
],
|
||||
],
|
||||
).toShadowContainer(context, padding: 12),
|
||||
)
|
||||
// ;
|
||||
// }
|
||||
//
|
||||
// )
|
||||
|
||||
.expanded,
|
||||
FooterActionButton.footerContainer(
|
||||
context: context,
|
||||
child: AppFilledButton(
|
||||
buttonColor: AppColor.primary10,
|
||||
label: "Activities",
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (_) => DemoActivitiesPage()));
|
||||
},
|
||||
),
|
||||
),
|
||||
FooterActionButton.footerContainer(
|
||||
context: context,
|
||||
child: AppFilledButton(
|
||||
buttonColor: AppColor.primary10,
|
||||
label: context.translation.update,
|
||||
onPressed: _update,
|
||||
),
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
List<Widget> requestDetails(BuildContext context, LoanRequestModel loanData) {
|
||||
return [
|
||||
Text("Request Details", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
||||
// 'Loan Type: ${loanData.loanTypeName ?? "-"}'.bodyText(context),
|
||||
'Demo No: ${loanData.reqCode ?? "-"}'.bodyText(context),
|
||||
'Demo Period: ${loanData.loanPeriodName ?? "-"}'.bodyText(context),
|
||||
'${context.translation.site}: ${loanData.siteName ?? "-"}'.bodyText(context),
|
||||
'${context.translation.department}: ${loanData.departmentName ?? "-"}'.bodyText(context),
|
||||
'Item Description: ${loanData.itemDescription ?? "-"}'.bodyText(context),
|
||||
'Request Description: ${loanData.requestDescription ?? "-"}'.bodyText(context),
|
||||
];
|
||||
}
|
||||
|
||||
List<Widget> vendorDetails(BuildContext context, LoanRequestModel loanData) {
|
||||
return [
|
||||
Text("Vendor Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
||||
'Name: ${loanData.vendorName ?? "-"}'.bodyText(context),
|
||||
'Representative Name: ${loanData.vendorRepName ?? "-"}'.bodyText(context),
|
||||
'Contact: ${loanData.vendorContact ?? "-"}'.bodyText(context),
|
||||
'Email: ${loanData.vendorEmail ?? "-"}'.bodyText(context),
|
||||
];
|
||||
}
|
||||
|
||||
List<Widget> assetDetails(BuildContext context, LoanRequestModel loanData) {
|
||||
return [
|
||||
Text("Asset Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
||||
// '${context.translation.assetName}: ${loanData.assetName ?? "-"}'.bodyText(context),
|
||||
// '${context.translation.assetNo}: ${loanData.assetNumber ?? "-"}'.bodyText(context),
|
||||
// '${context.translation.serialNumber}: ${loanData.assetSerialNumber ?? "-"}'.bodyText(context),
|
||||
'${context.translation.manufacture}: ${loanData.manufacturer ?? "-"}'.bodyText(context),
|
||||
'${context.translation.model}: ${loanData.model ?? "-"}'.bodyText(context),
|
||||
'Estimated Delivery Date: 29 October, 2025'.bodyText(context),
|
||||
];
|
||||
}
|
||||
|
||||
List<Widget> doctorDetails(BuildContext context, LoanRequestModel loanData) {
|
||||
return [
|
||||
Text("Doctor Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
||||
'Name: ${loanData.doctorName ?? "-"}'.bodyText(context),
|
||||
'Contact: ${loanData.doctorContact ?? "-"}'.bodyText(context),
|
||||
'Email: ${loanData.doctorEmail ?? "-"}'.bodyText(context),
|
||||
];
|
||||
}
|
||||
|
||||
List<Widget> requesterDetails(BuildContext context, LoanRequestModel loanData) {
|
||||
return [
|
||||
Text("Requester Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
||||
'Name: ${loanData.requestorUserIdForDisplay ?? "-"}'.bodyText(context),
|
||||
'Email: ${loanData.requestorUserEmail ?? "-"}'.bodyText(context),
|
||||
'Contact: ${loanData.requestorUserMobileNumber ?? "-"}'.bodyText(context),
|
||||
// 'Extension: ${loanData.requesterExtensionNo ?? "-"}'.bodyText(context),
|
||||
];
|
||||
}
|
||||
|
||||
void _update() {}
|
||||
}
|
||||
@ -0,0 +1,143 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/string_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/helper/utils.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/site_contact_info_model.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import '../../new_views/app_style/app_color.dart';
|
||||
import '../../new_views/common_widgets/app_filled_button.dart';
|
||||
import '../cm_module/views/components/action_button/footer_action_button.dart';
|
||||
import '../loan_module/provider/loan_period_provider.dart';
|
||||
|
||||
class DemoExtensionBottomSheet extends StatelessWidget {
|
||||
const DemoExtensionBottomSheet({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
clipBehavior: Clip.antiAlias,
|
||||
// height: MediaQuery.sizeOf(context).height * .5,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.only(
|
||||
topRight: Radius.circular(30),
|
||||
topLeft: Radius.circular(30),
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 8.toScreenHeight),
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 40.toScreenWidth,
|
||||
height: 5.toScreenHeight,
|
||||
decoration: BoxDecoration(color: AppColor.neutral40, borderRadius: BorderRadius.circular(30)),
|
||||
),
|
||||
16.height,
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Text(
|
||||
"Select Demo Period",
|
||||
style: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w600, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||
),
|
||||
),
|
||||
16.height,
|
||||
SingleItemDropDownMenu<Lookup, LoanPeriodProvider>(
|
||||
context: context,
|
||||
height: 56.toScreenHeight,
|
||||
title: 'Demo Period'.addTranslation,
|
||||
showShadow: false,
|
||||
validator: (value) {
|
||||
if (value == null) return "Please select loan period";
|
||||
return null;
|
||||
},
|
||||
backgroundColor: AppColor.fieldBgColor(context),
|
||||
showAsBottomSheet: true,
|
||||
// initialValue: _loanFormModel.loanProvided,
|
||||
onSelect: (status) {
|
||||
// if (status != null) {
|
||||
// _loanFormModel.loanProvided = status;
|
||||
// setState(() {});
|
||||
// }
|
||||
},
|
||||
),
|
||||
36.height,
|
||||
Row(
|
||||
children: [
|
||||
AppFilledButton(
|
||||
label: context.translation.cancel,
|
||||
buttonColor: AppColor.white60,
|
||||
textColor: AppColor.black10,
|
||||
loading: false,
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
).expanded,
|
||||
16.width,
|
||||
AppFilledButton(
|
||||
buttonColor: AppColor.primary10,
|
||||
label: context.translation.submit,
|
||||
onPressed: () {
|
||||
Utils.showLoading(context);
|
||||
Future.delayed(Duration(milliseconds: 500), () {
|
||||
// api call to submits
|
||||
Utils.hideLoading(context);
|
||||
Navigator.pop(context);
|
||||
// api call to get fresh data
|
||||
});
|
||||
},
|
||||
).expanded,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _launchWhatsapp(String number) async {
|
||||
var whatsappUrl = "https://wa.me/$number/?text=${Uri.parse("Hi, I need some help")}";
|
||||
try {
|
||||
if (await canLaunchUrlString(whatsappUrl)) {
|
||||
await launchUrlString(whatsappUrl);
|
||||
} else {
|
||||
throw 'Could not launch $whatsappUrl';
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error launching WhatsApp: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Widget contactItem(BuildContext context, bool isDark, String iconName, String title, String subtitle) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
"assets/images/$iconName.svg",
|
||||
width: 32.toScreenWidth,
|
||||
color: isDark ? AppColor.primary40 : AppColor.primary70,
|
||||
),
|
||||
30.height,
|
||||
Text(
|
||||
title,
|
||||
style: AppTextStyles.heading6.copyWith(color: isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||
),
|
||||
Text(
|
||||
subtitle,
|
||||
style: AppTextStyles.bodyText.copyWith(color: isDark ? AppColor.neutral10 : AppColor.neutral20),
|
||||
),
|
||||
],
|
||||
).toShadowContainer(context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/modules/loan_module/models/loan_request_model.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
class DemoProvider extends ChangeNotifier {
|
||||
Future<bool> addLoanRequest(Map<String, dynamic> body) async {
|
||||
try {
|
||||
Response response = await ApiManager.instance.post(URLs.addLoan, body: body, showToast: false);
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
String message = (jsonDecode(response.body)["data"] ?? "") + " " + (jsonDecode(response.body)["message"] ?? "");
|
||||
Fluttertoast.showToast(msg: message ?? "", toastLength: Toast.LENGTH_LONG);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool isLoading = false;
|
||||
|
||||
Future<LoanRequestModel?> getLoanById(int id) async {
|
||||
LoanRequestModel? loanData;
|
||||
try {
|
||||
Response response = await ApiManager.instance.get(URLs.getLoanById + "?loanId=$id");
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
loanData = LoanRequestModel.fromJson(json.decode(response.body)["data"]);
|
||||
}
|
||||
} catch (error) {
|
||||
print(error);
|
||||
}
|
||||
return loanData;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue