import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/health_calculator/doctor_list.dart';
import 'package:diplomaticquarterapp/widgets/buttons/button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:percent_indicator/circular_percent_indicator.dart';

class FatResult extends StatelessWidget {
  final double bodyFat;
  final double fat;
  final String textResult;

  FatResult({this.bodyFat, this.fat, this.textResult = ''});
  Color inductorColor;
  Color colorInductor() {
    if (bodyFat >= 17) {
      inductorColor = Color(0xffC70D00);
    } else if (bodyFat < 20 && bodyFat >= 24) {
      inductorColor = Color(0xffC25400);
    } else if (bodyFat < 24 && bodyFat >= 31) {
      inductorColor = Color(0xff36D600);
    } else if (bodyFat > 45) {
      inductorColor = Color(0xff1BE0EE);
    }
    return inductorColor;
  }

  @override
  Widget build(BuildContext context) {
    return AppScaffold(
      isShowAppBar: true,
      appBarTitle: 'Body Fat',
      body: Column(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: [
          SizedBox(
              // height: 40.0,
              ),
          Center(
            child: CircularPercentIndicator(
              radius: 220.0,
              lineWidth: 20.0,
              percent: ((fat > 70) ? 100 : fat / 100),
              center: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text(
                    fat.toStringAsFixed(1) + '%',
                    style: TextStyle(
                      fontSize: 18.0,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                  SizedBox(
                    height: 5.0,
                  ),
                ],
              ),
              progressColor: inductorColor,
              backgroundColor: Colors.white,
            ),
          ),
          Container(
            height: 120,
            width: 280.0,
            child: Texts(textResult),
          ),
          Container(
            width: 350,
            child: Button(
              label: 'See List Of Doctors',
              onTap: () {
                Navigator.push(
                  context,
                  FadePage(page: DoctorList()),
                );
              },
            ),
          ),
        ],
      ),
    );
  }
}
