Merge branch 'design_3.0_loan_module' into design_3.0_asset_delivery_module
# Conflicts: # lib/controllers/api_routes/urls.dartdesign_3.0_asset_delivery_module
commit
ce873d99a5
@ -0,0 +1,40 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:test_sa/models/timer_model.dart';
|
||||||
|
import 'package:test_sa/modules/loan_module/models/loan_form_model.dart';
|
||||||
|
|
||||||
|
class LoanInstallationPullOutFormModel {
|
||||||
|
String? snNo;
|
||||||
|
DateTime? date;
|
||||||
|
Uint8List? signature;
|
||||||
|
List<LoanAttachments>? loanAttachment;
|
||||||
|
TimerModel? timerModel = TimerModel();
|
||||||
|
DateTime? startTime;
|
||||||
|
DateTime? endTime;
|
||||||
|
double? totalHours;
|
||||||
|
|
||||||
|
LoanInstallationPullOutFormModel({
|
||||||
|
this.loanAttachment,
|
||||||
|
this.timerModel,
|
||||||
|
this.snNo,
|
||||||
|
this.signature,
|
||||||
|
this.date,
|
||||||
|
this.startTime,
|
||||||
|
this.endTime,
|
||||||
|
this.totalHours,
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
//Need to check payload parm they need
|
||||||
|
return {
|
||||||
|
'snNo': snNo,
|
||||||
|
'InstallationDate': date?.toIso8601String(),
|
||||||
|
"loanAttachments": loanAttachment != null ? loanAttachment!.map((v) => v.toJson()).toList() : [],
|
||||||
|
"signature": signature != null ? "${DateTime.now().toIso8601String()}.png|${base64Encode(signature!)}" : null,
|
||||||
|
'startTime': startTime?.toIso8601String(),
|
||||||
|
'endTime': endTime?.toIso8601String(),
|
||||||
|
'totalHours': totalHours,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,187 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.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/models/generic_attachment_model.dart';
|
||||||
|
import 'package:test_sa/models/timer_model.dart';
|
||||||
|
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
||||||
|
import 'package:test_sa/modules/loan_module/models/loan_installation_pullout_form_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 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
|
||||||
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
||||||
|
import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
|
||||||
|
import 'package:test_sa/views/widgets/e_signature/e_signature.dart';
|
||||||
|
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
|
||||||
|
import 'package:test_sa/views/widgets/timer/app_timer.dart';
|
||||||
|
|
||||||
|
class InstallationPullOutFormView extends StatefulWidget {
|
||||||
|
final bool isPullout;
|
||||||
|
final String? createdDate;
|
||||||
|
|
||||||
|
const InstallationPullOutFormView({super.key, required this.isPullout, this.createdDate});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<InstallationPullOutFormView> createState() => _InstallationPullOutFormViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _InstallationPullOutFormViewState extends State<InstallationPullOutFormView> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
final _snController = TextEditingController();
|
||||||
|
List<GenericAttachmentModel> _attachments = [];
|
||||||
|
final _formData = LoanInstallationPullOutFormModel();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_snController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _pickInstallationDate(DateTime date) async {
|
||||||
|
final time = await showTimePicker(
|
||||||
|
context: context,
|
||||||
|
initialTime: TimeOfDay.now(),
|
||||||
|
);
|
||||||
|
if (time == null) return;
|
||||||
|
setState(() {
|
||||||
|
_formData.date = DateTime(
|
||||||
|
date.year,
|
||||||
|
date.month,
|
||||||
|
date.day,
|
||||||
|
time.hour,
|
||||||
|
time.minute,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onSignatureChanged(Uint8List signature) {
|
||||||
|
if (signature.isEmpty) return;
|
||||||
|
setState(() {
|
||||||
|
_formData.signature = signature;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _submitForm() {
|
||||||
|
if (!_formKey.currentState!.validate()) return;
|
||||||
|
//Validation if required .
|
||||||
|
|
||||||
|
// if (_formData.date == null) {
|
||||||
|
// context.showSnackBar('Please select installation date');
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (_formData.signature == null || _formData.signature!.isEmpty) {
|
||||||
|
// context.showSnackBar('Signature is required');
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
_formData.snNo = _snController.text;
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateTimer({TimerModel? timer}) {
|
||||||
|
if (timer?.startAt != null && timer?.endAt != null) {
|
||||||
|
final start = timer!.startAt!;
|
||||||
|
final end = timer.endAt!;
|
||||||
|
final difference = end.difference(start);
|
||||||
|
final totalHours = difference.inSeconds / 3600.0;
|
||||||
|
_formData.startTime = start;
|
||||||
|
_formData.endTime = end;
|
||||||
|
_formData.totalHours = totalHours;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: widget.isPullout ? null : DefaultAppBar(title: 'Installation Report'.addTranslation),
|
||||||
|
body: SafeArea(
|
||||||
|
child: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
if (!widget.isPullout) ...[
|
||||||
|
AppTextFormField(
|
||||||
|
controller: _snController,
|
||||||
|
labelText: context.translation.snNo,
|
||||||
|
backgroundColor: AppColor.fieldBgColor(context),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
||||||
|
hintStyle: AppTextStyles.textFieldLabelStyle,
|
||||||
|
textInputType: TextInputType.text,
|
||||||
|
textInputAction: TextInputAction.next,
|
||||||
|
showShadow: false,
|
||||||
|
validator: (v) => (v == null || v.isEmpty) ? 'Required' : null,
|
||||||
|
),
|
||||||
|
8.height,
|
||||||
|
],
|
||||||
|
ADatePicker(
|
||||||
|
label: !widget.isPullout ? "Installation Date".addTranslation : "Validation Date".addTranslation,
|
||||||
|
hideShadow: true,
|
||||||
|
backgroundColor: AppColor.fieldBgColor(context),
|
||||||
|
to: DateTime.now().add(const Duration(days: 365)),
|
||||||
|
formatDateWithTime: true,
|
||||||
|
onDatePicker: _pickInstallationDate,
|
||||||
|
),
|
||||||
|
8.height,
|
||||||
|
AppTimer(
|
||||||
|
label: context.translation.workingHours,
|
||||||
|
timer: _formData.timerModel,
|
||||||
|
// pickerFromDate: DateTime.tryParse(widget.createdDate ?? ''),
|
||||||
|
pickerFromDate: DateTime(DateTime.now().year, DateTime.now().month, 1),
|
||||||
|
pickerTimer: _formData.timerModel,
|
||||||
|
showTimer: false,
|
||||||
|
onPick: (timer) {
|
||||||
|
updateTimer(timer: timer);
|
||||||
|
},
|
||||||
|
width: double.infinity,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColor.fieldBgColor(context),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
timerProgress: (isRunning) {},
|
||||||
|
onChange: (timer) async {
|
||||||
|
updateTimer(timer: timer);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ESignature(
|
||||||
|
title: 'End-user signature'.addTranslation,
|
||||||
|
backgroundColor: AppColor.fieldBgColor(context),
|
||||||
|
showShadow: false,
|
||||||
|
oldSignature: '',
|
||||||
|
newSignature: _formData.signature,
|
||||||
|
onChange: _onSignatureChanged,
|
||||||
|
),
|
||||||
|
24.height,
|
||||||
|
AttachmentPicker(
|
||||||
|
label: context.translation.attachments,
|
||||||
|
attachment: _attachments,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).toShadowContainer(context, borderRadius: 20),
|
||||||
|
).expanded,
|
||||||
|
FooterActionButton.footerContainer(
|
||||||
|
context: context,
|
||||||
|
child: AppFilledButton(
|
||||||
|
buttonColor: AppColor.primary10,
|
||||||
|
label: context.translation.submitRequest,
|
||||||
|
onPressed: _submitForm,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,87 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:test_sa/controllers/api_routes/urls.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/modules/loan_module/models/loan_request_model.dart';
|
||||||
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||||
|
import 'package:test_sa/views/widgets/images/files_list.dart';
|
||||||
|
|
||||||
|
class InstallationDetailsView extends StatelessWidget {
|
||||||
|
final LoanRequestModel loanData;
|
||||||
|
|
||||||
|
const InstallationDetailsView({super.key, required this.loanData});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
detailContent(
|
||||||
|
context: context,
|
||||||
|
heading: 'Updates SN:',
|
||||||
|
label: loanData.installationDate??'-'
|
||||||
|
),
|
||||||
|
detailContent(
|
||||||
|
context: context,
|
||||||
|
heading: 'Installation Date',
|
||||||
|
label: loanData.installationDate??'-'
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
detailContent(
|
||||||
|
context: context,
|
||||||
|
heading: 'Start Time',
|
||||||
|
label: loanData.installationDate??'-'
|
||||||
|
),
|
||||||
|
detailContent(
|
||||||
|
context: context,
|
||||||
|
heading: 'End Time',
|
||||||
|
label: loanData.installationDate??'-'
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
detailContent(
|
||||||
|
context: context,
|
||||||
|
heading: 'Total Time',
|
||||||
|
label: loanData.installationDate??'-'
|
||||||
|
),
|
||||||
|
if (loanData.loanAttachments!.isNotEmpty) ...[
|
||||||
|
12.height,
|
||||||
|
Text(
|
||||||
|
"Uploads Phase 2 docs".addTranslation,
|
||||||
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||||
|
),
|
||||||
|
8.height,
|
||||||
|
FilesList(images: loanData.loanAttachments?.map((e) => URLs.getFileUrl(e.attachmentName ?? '') ?? '').toList() ?? []),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
).toShadowContainer(context, borderRadius: 20),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget detailContent({required BuildContext context, required String label, required String heading}) {
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
heading.bodyText(context).custom(color: AppColor.neutral120),
|
||||||
|
6.height,
|
||||||
|
//TODO Need to check which value need to show here
|
||||||
|
label.bodyText(context).custom(color: AppColor.neutral120),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,80 @@
|
|||||||
|
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/text_extensions.dart';
|
||||||
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||||
|
import 'package:test_sa/modules/loan_module/models/loan_request_model.dart';
|
||||||
|
import 'package:test_sa/modules/loan_module/pages/installation_pullout_form_view.dart';
|
||||||
|
import 'package:test_sa/modules/loan_module/pages/intallation_details_view.dart';
|
||||||
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||||
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
||||||
|
|
||||||
|
class PullOutDetailsPage extends StatefulWidget {
|
||||||
|
final LoanRequestModel? loanData;
|
||||||
|
|
||||||
|
PullOutDetailsPage({Key? key, required this.loanData}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_PullOutDetailsPageState createState() {
|
||||||
|
return _PullOutDetailsPageState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PullOutDetailsPageState extends State<PullOutDetailsPage> {
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
appBar: DefaultAppBar(
|
||||||
|
title: 'Loan Request'.addTranslation,
|
||||||
|
),
|
||||||
|
body: DefaultTabController(
|
||||||
|
length: 2,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.only(left: 16.toScreenWidth, right: 16.toScreenWidth, top: 12.toScreenHeight),
|
||||||
|
decoration: BoxDecoration(color: context.isDark ? AppColor.neutral50 : AppColor.white10, borderRadius: BorderRadius.circular(10)),
|
||||||
|
child: TabBar(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 4.toScreenHeight, horizontal: 4.toScreenWidth),
|
||||||
|
labelColor: context.isDark ? AppColor.neutral30 : AppColor.black20,
|
||||||
|
unselectedLabelColor: context.isDark ? AppColor.neutral30 : AppColor.black20,
|
||||||
|
unselectedLabelStyle: AppTextStyles.bodyText,
|
||||||
|
labelStyle: AppTextStyles.bodyText,
|
||||||
|
indicatorPadding: EdgeInsets.zero,
|
||||||
|
indicatorSize: TabBarIndicatorSize.tab,
|
||||||
|
dividerColor: Colors.transparent,
|
||||||
|
indicator: BoxDecoration(color: context.isDark ? AppColor.neutral60 : AppColor.neutral110, borderRadius: BorderRadius.circular(7)),
|
||||||
|
onTap: (index) {
|
||||||
|
// setState(() {});
|
||||||
|
},
|
||||||
|
tabs: [
|
||||||
|
Tab(text: 'Installation'.addTranslation, height: 57.toScreenHeight),
|
||||||
|
Tab(text: 'Pull Out'.addTranslation, height: 57.toScreenHeight),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
TabBarView(
|
||||||
|
children: [
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
child: InstallationDetailsView(
|
||||||
|
loanData: widget.loanData!,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const InstallationPullOutFormView(isPullout: true),
|
||||||
|
],
|
||||||
|
).expanded,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue