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: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/models/pantry/ppm_check_list.dart';
|
||||||
import 'package:test_sa/views/app_style/sizing.dart';
|
import 'package:test_sa/new_views/app_style/app_color.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';
|
|
||||||
|
|
||||||
class PentryPMChecklistForm extends StatefulWidget {
|
class PentryPMChecklistForm extends StatefulWidget {
|
||||||
final List<PPMCheckList> models;
|
final List<PPMCheckList> models;
|
||||||
final bool enableValidate;
|
final bool enableValidate;
|
||||||
|
|
||||||
const PentryPMChecklistForm({
|
const PentryPMChecklistForm({Key key, this.models, this.enableValidate}) : super(key: key);
|
||||||
Key key,
|
|
||||||
this.models,
|
|
||||||
this.enableValidate,
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PentryPMChecklistForm> createState() => _PentryPMChecklistFormState();
|
State<PentryPMChecklistForm> createState() => _PentryPMChecklistFormState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PentryPMChecklistFormState extends State<PentryPMChecklistForm> {
|
class _PentryPMChecklistFormState extends State<PentryPMChecklistForm> {
|
||||||
|
PPMCheckList item = PPMCheckList();
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(top: 16.toScreenHeight),
|
||||||
top: 12 * AppStyle.getScaleFactor(context), left: 12 * AppStyle.getScaleFactor(context), right: 12 * AppStyle.getScaleFactor(context), bottom: 80 * AppStyle.getScaleFactor(context)),
|
itemCount: widget.models.length,
|
||||||
itemCount: widget.models.length + 1,
|
shrinkWrap: true,
|
||||||
itemBuilder: (context, index) {
|
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];
|
final model = widget.models[index];
|
||||||
return ListView(
|
return Card(
|
||||||
shrinkWrap: true,
|
child: ExpansionTile(
|
||||||
physics: const ClampingScrollPhysics(),
|
shape: const Border(),
|
||||||
children: [
|
title: (model.title ?? "").heading5(context),
|
||||||
Row(
|
subtitle: "Status ${model.status?.name}".bodyText(context),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
initiallyExpanded: index == 0,
|
||||||
children: [
|
iconColor: AppColor.neutral50,
|
||||||
ASubTitle("#${index + 1}"),
|
collapsedIconColor: AppColor.neutral50,
|
||||||
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,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue