112 lines
3.4 KiB
Dart
112 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:ftc_mobile_app/ftc_mobile_app.dart';
|
|
import 'package:ftc_mobile_app/models/training/TrainingResponseData.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import 'controller/trainings_screen_controller.dart';
|
|
import 'training_detail_screen.dart';
|
|
|
|
class TrainingsScreen extends StatefulWidget {
|
|
const TrainingsScreen({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<TrainingsScreen> createState() => _TrainingsScreenState();
|
|
}
|
|
|
|
class _TrainingsScreenState extends State<TrainingsScreen> {
|
|
final controller = Get.put(TrainingsScreenController());
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return CustomScaffold(
|
|
backgroundColor: CustomAppColors.kSmokeColor,
|
|
screenKey: controller.screenKey,
|
|
onScreenTap: controller.removeFocus,
|
|
showAppBar: true,
|
|
appBar: CustomAppBarTitleOnly(
|
|
context,
|
|
titleText: "Training",
|
|
),
|
|
body: SafeArea(
|
|
child: _listView(),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _listView() {
|
|
return Obx(() {
|
|
final list = controller.trainings();
|
|
return (list.isEmpty)
|
|
? Container(
|
|
color: Colors.white,
|
|
child: const Center(
|
|
child: Text("No data found"),
|
|
),
|
|
)
|
|
: ListView.separated(
|
|
itemCount: list.length,
|
|
itemBuilder: (_, index) {
|
|
final item = list[index];
|
|
return _listItem(item);
|
|
},
|
|
separatorBuilder: (_, i) => 8.verticalSpace,
|
|
);
|
|
});
|
|
}
|
|
|
|
Widget _listItem(TrainingUsers item) {
|
|
return InkWell(
|
|
onTap: () {
|
|
Get.toNamed(CustomRouteNames.kTrainingDetailScreen,
|
|
arguments: TrainingDetailScreenArgs(data: item));
|
|
},
|
|
child: Container(
|
|
decoration: const BoxDecoration(color: Colors.white),
|
|
padding: REdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
CustomTextWidget(
|
|
text: item.trainingId?.prpsName ?? "",
|
|
textAlign: TextAlign.left,
|
|
fontSize: 16.sp,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
CustomTextWidget(
|
|
text:
|
|
"Start date: ${DateFormatter.dateFormatter2.format(DateTime.fromMillisecondsSinceEpoch(item.trainingId?.prpsTrgStartDate ?? 0).toLocal())}",
|
|
fontColor: Colors.grey,
|
|
textAlign: TextAlign.left,
|
|
fontSize: 12.sp,
|
|
),
|
|
4.verticalSpace,
|
|
CustomTextWidget(
|
|
text:
|
|
"Status: ${item.trainingId?.prpsTrgStatus?.capitalizeFirst ?? ""}",
|
|
textAlign: TextAlign.left,
|
|
fontColor: Colors.black,
|
|
fontSize: 14.sp,
|
|
maxLines: 3,
|
|
fontWeight: FontWeight.w500,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
const Icon(Icons.keyboard_arrow_right_rounded)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
controller.dispose();
|
|
super.dispose();
|
|
}
|
|
}
|