fist commit ftc staff app clone
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:ftc_mobile_app/models/training/TrainingResponseData.dart';
|
||||
import 'package:ftc_mobile_app/utilities/extensions/custom_extensions.dart';
|
||||
import 'package:ftc_mobile_app/utilities/frequent_functions.dart';
|
||||
import 'package:ftc_mobile_app/web_services/api_services.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class TrainingsScreenController extends GetxController {
|
||||
final GlobalKey<ScaffoldState> screenKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
final trainings = <TrainingUsers>[].obs;
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
|
||||
getAllTrainings();
|
||||
}
|
||||
|
||||
void removeFocus() {
|
||||
FocusScope.of(screenKey.currentContext!).unfocus();
|
||||
}
|
||||
|
||||
getAllTrainings() async {
|
||||
final resp = await ApiService().allTrainingsList().showLoader();
|
||||
|
||||
if (resp is TrainingResponseData) {
|
||||
//Todo: change this static user id here
|
||||
trainings.value = resp.proposedTrainings ?? [];
|
||||
} else {
|
||||
if (resp.isNotNullOrEmpty()) {
|
||||
FrequentFunctions.showToast(message: resp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
Get.delete<TrainingsScreenController>();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
149
lib/view/screens/training/training_detail_screen.dart
Normal file
149
lib/view/screens/training/training_detail_screen.dart
Normal file
@@ -0,0 +1,149 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:ftc_mobile_app/ftc_mobile_app.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:ftc_mobile_app/models/training/TrainingResponseData.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class TrainingDetailScreenArgs {
|
||||
final TrainingUsers data;
|
||||
|
||||
TrainingDetailScreenArgs({required this.data});
|
||||
}
|
||||
|
||||
class TrainingDetailScreen extends StatefulWidget {
|
||||
final TrainingDetailScreenArgs args;
|
||||
|
||||
const TrainingDetailScreen({super.key, required this.args});
|
||||
|
||||
@override
|
||||
State<TrainingDetailScreen> createState() => _TrainingDetailScreenState();
|
||||
}
|
||||
|
||||
class _TrainingDetailScreenState extends State<TrainingDetailScreen> {
|
||||
ProposedTrainings? get _data => widget.args.data.trainingId;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomScaffold(
|
||||
backgroundColor: CustomAppColors.kWhiteColor,
|
||||
screenKey: GlobalKey(),
|
||||
onScreenTap: Get.focusScope?.unfocus,
|
||||
showAppBar: true,
|
||||
appBar: AppBar(
|
||||
automaticallyImplyLeading: false,
|
||||
title: CustomTextWidget(
|
||||
text: "${_data?.prpsTrgType?.capitalizeFirst ?? ""} Training",
|
||||
fontColor: Colors.white,
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
centerTitle: false,
|
||||
actions: const [
|
||||
CloseButton(color: Colors.white),
|
||||
],
|
||||
),
|
||||
body: SafeArea(
|
||||
child: ListView(
|
||||
padding: REdgeInsets.symmetric(horizontal: 20),
|
||||
children: [
|
||||
16.verticalSpace,
|
||||
_headerValueWidget(
|
||||
heading: 'Training Title',
|
||||
value: _data?.prpsName ?? "",
|
||||
),
|
||||
16.verticalSpace,
|
||||
_headerValueWidget(
|
||||
heading: 'Introduction',
|
||||
value: _data?.prpsDescription ?? "",
|
||||
),
|
||||
16.verticalSpace,
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _headerValueWidget(
|
||||
heading: 'Training Start Date',
|
||||
value: DateFormatter.dateFormatter2.format(
|
||||
DateTime.fromMillisecondsSinceEpoch(
|
||||
_data?.prpsTrgStartDate ?? 0)),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: _headerValueWidget(
|
||||
heading: 'Training End Date',
|
||||
value: DateFormatter.dateFormatter2.format(
|
||||
DateTime.fromMillisecondsSinceEpoch(
|
||||
_data?.prpsTrgEndDate ?? 0)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
16.verticalSpace,
|
||||
_headerValueWidget(
|
||||
heading: 'Training Registration Date',
|
||||
value: DateFormatter.dateFormatter2.format(
|
||||
DateTime.fromMillisecondsSinceEpoch(
|
||||
_data?.prpsTrgRegisterationDate ?? 0)),
|
||||
),
|
||||
16.verticalSpace,
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _headerValueWidget(
|
||||
heading: 'Training Type',
|
||||
value: _data?.prpsTrgType?.capitalizeFirst ?? "",
|
||||
),
|
||||
),
|
||||
12.horizontalSpace,
|
||||
Expanded(
|
||||
child: _headerValueWidget(
|
||||
heading: 'Training Type',
|
||||
value: _data?.prpsTrgClass?.capitalizeFirst ?? "",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
16.verticalSpace,
|
||||
_headerValueWidget(
|
||||
heading: 'Training Status',
|
||||
value: _data?.prpsTrgStatus?.capitalizeFirst ?? "",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _headerValueWidget({required String heading, required String value}) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_heading(heading),
|
||||
3.verticalSpace,
|
||||
_subtext(value),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _heading(String text) {
|
||||
return Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 14.sp,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.black,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _subtext(String text) {
|
||||
return Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 12.sp,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
111
lib/view/screens/training/training_screen.dart
Normal file
111
lib/view/screens/training/training_screen.dart
Normal file
@@ -0,0 +1,111 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user