PPM in progress
parent
2ebf36ca2f
commit
8541fce08f
@ -0,0 +1,35 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||
|
||||
import '../../../controllers/api_routes/api_manager.dart';
|
||||
import '../../../controllers/api_routes/urls.dart';
|
||||
|
||||
class PentryTaskStatusProvider extends LoadingListNotifier<Lookup> {
|
||||
@override
|
||||
Future getDate() async {
|
||||
if (loading ?? false) return -2;
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(URLs.getPentryTaskStatus);
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List listJson = json.decode(response.body)["data"];
|
||||
items = listJson.map((department) => Lookup.fromJson(department)).toList();
|
||||
}
|
||||
loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
}
|
||||
}
|
||||
@ -1,133 +1,40 @@
|
||||
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/text_extensions.dart';
|
||||
import 'package:test_sa/models/pantry/ppm_check_list.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
|
||||
import 'package:test_sa/views/widgets/status/pentry/pentry_task_status_mune.dart';
|
||||
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
|
||||
class PentryPMChecklistForm extends StatefulWidget {
|
||||
final List<PPMCheckList> models;
|
||||
final bool enableValidate;
|
||||
|
||||
const PentryPMChecklistForm({
|
||||
Key key,
|
||||
this.models,
|
||||
this.enableValidate,
|
||||
}) : super(key: key);
|
||||
const PentryPMChecklistForm({Key key, this.models, this.enableValidate}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<PentryPMChecklistForm> createState() => _PentryPMChecklistFormState();
|
||||
}
|
||||
|
||||
class _PentryPMChecklistFormState extends State<PentryPMChecklistForm> {
|
||||
PPMCheckList item = PPMCheckList();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.builder(
|
||||
padding: EdgeInsets.only(
|
||||
top: 12 * AppStyle.getScaleFactor(context), left: 12 * AppStyle.getScaleFactor(context), right: 12 * AppStyle.getScaleFactor(context), bottom: 80 * AppStyle.getScaleFactor(context)),
|
||||
itemCount: widget.models.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == widget.models.length) {
|
||||
return AButton(
|
||||
text: context.translation.add,
|
||||
onPressed: () {
|
||||
widget.models.add(PPMCheckList());
|
||||
setState(() {});
|
||||
},
|
||||
);
|
||||
}
|
||||
final model = widget.models[index];
|
||||
return ListView(
|
||||
shrinkWrap: true,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ASubTitle("#${index + 1}"),
|
||||
if (index != 0)
|
||||
ASmallButton(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
text: context.translation.delete,
|
||||
onPressed: () {
|
||||
widget.models.remove(model);
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
const ASubTitle("Task"),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
ATextFormField(
|
||||
initialValue: (model.title ?? "").toString(),
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
textInputType: TextInputType.text,
|
||||
onChange: (value) {
|
||||
model.title = value;
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
ASubTitle(context.translation.status),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
PentryTaskStatusMenu(
|
||||
initialValue: model.status,
|
||||
onSelect: (status) {
|
||||
model.status = status;
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
const ASubTitle("Comment"),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
ATextFormField(
|
||||
initialValue: (model.comment ?? "").toString(),
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
textInputType: TextInputType.text,
|
||||
onChange: (value) {
|
||||
model.comment = value;
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
const ASubTitle("Measured Value"),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
ATextFormField(
|
||||
initialValue: (model.measuredValue ?? "").toString(),
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
textInputType: TextInputType.text,
|
||||
onChange: (value) {
|
||||
model.measuredValue = value;
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Divider(
|
||||
color: Theme.of(context).textTheme.titleMedium.color,
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
padding: EdgeInsets.only(top: 16.toScreenHeight),
|
||||
itemCount: widget.models.length,
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (context, index) {
|
||||
final model = widget.models[index];
|
||||
return Card(
|
||||
child: ExpansionTile(
|
||||
shape: const Border(),
|
||||
title: (model.title ?? "").heading5(context),
|
||||
subtitle: "Status ${model.status?.name}".bodyText(context),
|
||||
initiallyExpanded: index == 0,
|
||||
iconColor: AppColor.neutral50,
|
||||
collapsedIconColor: AppColor.neutral50,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue