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 { List 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); } } }