performance evaluation improvements.
parent
2eedef7c2c
commit
8e94d57dae
@ -1,114 +0,0 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:mohem_flutter_app/api/profile_api_client.dart';
|
|
||||||
import 'package:mohem_flutter_app/classes/colors.dart';
|
|
||||||
import 'package:mohem_flutter_app/classes/utils.dart';
|
|
||||||
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
|
||||||
import 'package:mohem_flutter_app/models/performance.dart';
|
|
||||||
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
|
||||||
|
|
||||||
class PerformanceAppraisal extends StatefulWidget {
|
|
||||||
const PerformanceAppraisal({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
_PerformanceAppraisalState createState() => _PerformanceAppraisalState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _PerformanceAppraisalState extends State<PerformanceAppraisal> {
|
|
||||||
List<GetPerformanceAppraisalList> performance = [];
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
getPerformanceAppraisal();
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: MyColors.backgroundColor,
|
|
||||||
appBar: AppBarWidget(
|
|
||||||
context,
|
|
||||||
title: LocaleKeys.performance.tr(),
|
|
||||||
),
|
|
||||||
body: performance.isNotEmpty
|
|
||||||
? SingleChildScrollView(
|
|
||||||
child: Container(
|
|
||||||
width: double.infinity,
|
|
||||||
padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10),
|
|
||||||
child: Column(children: [
|
|
||||||
Row(children: [Expanded(flex: 1, child: getPerformanceCard(performance.first))]),
|
|
||||||
GridView.count(
|
|
||||||
crossAxisCount: 2,
|
|
||||||
shrinkWrap: true,
|
|
||||||
childAspectRatio:1.3,
|
|
||||||
children: performance
|
|
||||||
.where((GetPerformanceAppraisalList el) => performance.indexOf(el) != 0)
|
|
||||||
.map(
|
|
||||||
(GetPerformanceAppraisalList item) => getPerformanceCard(item),
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
)
|
|
||||||
])))
|
|
||||||
: Utils.getNoDataWidget(context),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget getPerformanceCard(GetPerformanceAppraisalList performance) {
|
|
||||||
return Card(
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10.0),
|
|
||||||
),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(15),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
LocaleKeys.performanceEvaluationIn.tr() + performance.aPPRAISALYEAR.toString(),
|
|
||||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
SliderTheme(
|
|
||||||
data: SliderThemeData(trackHeight: 3, thumbShape: SliderComponentShape.noThumb, overlayShape: SliderComponentShape.noOverlay),
|
|
||||||
child: Slider(
|
|
||||||
max: 100,
|
|
||||||
min: 0,
|
|
||||||
inactiveColor: Colors.grey.withOpacity(.4),
|
|
||||||
activeColor: Colors.green,
|
|
||||||
value: double.parse(performance.aPPRAISALSCORE!),
|
|
||||||
onChanged: (value) {},
|
|
||||||
semanticFormatterCallback: (double newValue) {
|
|
||||||
return '${newValue.round()}';
|
|
||||||
})),
|
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
performance.aPPRAISALSCORE.toString() + '%',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 18,
|
|
||||||
color: Colors.green,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void getPerformanceAppraisal() async {
|
|
||||||
try {
|
|
||||||
Utils.showLoading(context);
|
|
||||||
performance = (await ProfileApiClient().getPerformanceAppraisal())!;
|
|
||||||
setState(() {});
|
|
||||||
Utils.hideLoading(context);
|
|
||||||
} catch (ex) {
|
|
||||||
Utils.hideLoading(context);
|
|
||||||
Utils.handleException(ex, context, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,97 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mohem_flutter_app/api/profile_api_client.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/performance.dart';
|
||||||
|
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
||||||
|
|
||||||
|
class PerformanceAppraisal extends StatelessWidget {
|
||||||
|
PerformanceAppraisal({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
Future<List<GetPerformanceAppraisalList>> getPerformanceAppraisal(context) async {
|
||||||
|
List<GetPerformanceAppraisalList> performance = [];
|
||||||
|
try {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
performance = await ProfileApiClient().getPerformanceAppraisal();
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
} catch (ex) {
|
||||||
|
performance = [];
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
Utils.handleException(ex, context, null);
|
||||||
|
}
|
||||||
|
return performance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: MyColors.backgroundColor,
|
||||||
|
appBar: AppBarWidget(context, title: LocaleKeys.performance.tr()),
|
||||||
|
body: FutureBuilder(
|
||||||
|
future: getPerformanceAppraisal(context),
|
||||||
|
builder: (cxt, snapShot) {
|
||||||
|
if (snapShot.connectionState == ConnectionState.done) {
|
||||||
|
if (snapShot.hasData) {
|
||||||
|
List<GetPerformanceAppraisalList> performance = snapShot.data as List<GetPerformanceAppraisalList>;
|
||||||
|
if (performance.isNotEmpty) {
|
||||||
|
return ListView(
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
children: [
|
||||||
|
getPerformanceCard(performance.first).paddingOnly(left: 21, right: 21, top: 21),
|
||||||
|
GridView.count(
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
crossAxisCount: 2,
|
||||||
|
mainAxisSpacing: 13,
|
||||||
|
crossAxisSpacing: 13,
|
||||||
|
shrinkWrap: true,
|
||||||
|
childAspectRatio: 160 / 125,
|
||||||
|
padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21, top: 14),
|
||||||
|
children: performance
|
||||||
|
.where((GetPerformanceAppraisalList el) => performance.indexOf(el) != 0)
|
||||||
|
.map(
|
||||||
|
(GetPerformanceAppraisalList item) => getPerformanceCard(item, isGrid: true),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Utils.getNoDataWidget(context);
|
||||||
|
}
|
||||||
|
return const SizedBox();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getPerformanceCard(GetPerformanceAppraisalList performance, {bool isGrid = false}) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.only(left: 12, right: 12, top: 2, bottom: 2),
|
||||||
|
decoration: Utils.containerRadius(MyColors.greenColor, 5),
|
||||||
|
child: "Excellent".toText10(color: Colors.white),
|
||||||
|
),
|
||||||
|
(isGrid ? 8 : 4).height,
|
||||||
|
isGrid ? "${LocaleKeys.performanceEvaluationIn.tr()} ${performance.aPPRAISALYEAR}".toText13() : "${LocaleKeys.performanceEvaluationIn.tr()} ${performance.aPPRAISALYEAR}".toText18(),
|
||||||
|
4.height,
|
||||||
|
LinearProgressIndicator(
|
||||||
|
minHeight: 4,
|
||||||
|
backgroundColor: MyColors.lightGreyDeColor,
|
||||||
|
valueColor: const AlwaysStoppedAnimation<Color>(MyColors.greenColor),
|
||||||
|
value: double.parse(performance.aPPRAISALSCORE!) / 100,
|
||||||
|
),
|
||||||
|
4.height,
|
||||||
|
isGrid ? "${performance.aPPRAISALSCORE}%".toText13(color: MyColors.greenColor) : "${performance.aPPRAISALSCORE}%".toText20(color: MyColors.greenColor),
|
||||||
|
],
|
||||||
|
).objectContainerView(radius: 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue