One UI in flutter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
3.6 KiB

2 years ago
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../model/ac_mou_response_model.dart';
import '../screen/md_lab_mitra/mitra_lookup_mou_provider.dart';
2 years ago
import 'fx_data_mitra.dart';
import 'fx_error_text.dart';
2 years ago
import 'provider/selectedCompanyProvider.dart';
2 years ago
class FxMitraMou extends HookConsumerWidget {
final double? width;
final String? errorValidation;
2 years ago
const FxMitraMou({
Key? key,
this.width,
this.errorValidation,
2 years ago
}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
final listMou = useState<List<AcMouResponseModel>>(List.empty());
final companyModel = ref.watch(selectedAcCompanyProvider);
2 years ago
String companyName = companyModel?.mCompanyName ?? "";
2 years ago
ref.listen(mitraLookupMouProvider, (prev, next) {
if (next is MitraLookupMouStateDone) {
2 years ago
for (int idx = 0; idx < next.list.length; idx++) {
next.list[idx].isCheck = false;
}
2 years ago
listMou.value = next.list;
}
});
return Container(
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: errorValidation == null
? Colors.blue.shade700
: Colors.red.shade700,
),
2 years ago
color: Colors.blue.shade100.withOpacity(0.3),
),
child: ConstrainedBox(
2 years ago
constraints: BoxConstraints.loose(const Size(double.infinity, 150)),
2 years ago
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
errorValidation == null
? FxNormalBlueText(
title: "Agreement $companyName",
isBold: true,
)
: FxErrorText(
title: "Agreement $companyName *) $errorValidation"),
2 years ago
const SizedBox(height: 10),
if (listMou.value.isNotEmpty)
ConstrainedBox(
constraints:
BoxConstraints.loose(const Size(double.infinity, 100)),
2 years ago
child: ListView.builder(
2 years ago
shrinkWrap: true,
2 years ago
itemCount: listMou.value.length,
itemBuilder: (context, idx) {
final model = listMou.value[idx];
2 years ago
return Row(
children: [
Checkbox(
value: model.isCheck,
onChanged: ((val) {
final List<AcMouResponseModel> list =
List.empty(growable: true);
list.addAll(listMou.value);
list[idx].isCheck = val ?? false;
listMou.value = list;
ref.read(selectedMouProvider.notifier).state =
list.where((el) => el.isCheck).toList();
2 years ago
}),
),
const SizedBox(width: 10),
Expanded(
child: FxNormalBlueText(title: model.mMouName),
),
],
);
2 years ago
}),
),
]),
),
),
);
}
}