import 'package:flutter/material.dart';
import 'package:rkm/config/color_palette.dart';
import 'package:rkm/config/const_variable.dart';
import 'package:rkm/widgets/text_default.dart';
import 'package:sqflite/sqflite.dart';
import '../service/db/db_sqlite_load.dart';
import '../widgets/appbar_default.dart';

class AttendanceListScreen extends StatefulWidget {
  String username;

  AttendanceListScreen({required this.username});

  @override
  State<AttendanceListScreen> createState() => _AttendanceListScreenState();
}

class _AttendanceListScreenState extends State<AttendanceListScreen> {

  List visitHome = [];
  List citizenUpdate = [];
  List serviceHome = [];

  getData()async{
    Database db = await DbSqliteLoad().intialDB();
    visitHome = await db.query('VISITAS_DOMICILIARES_PROC');
    citizenUpdate = await db.query('CIDADAOS WHERE SINCRONIZADO = "N"');
    serviceHome =await db.query('ATENDS_DOM_PROC');
    print(await db.query('ATENDS_DOM_PROC'));
    // print(await db.query('VISITAS_DOMICILIARES_PROC'));
    // print(await db.query('CIDADAOS WHERE SINCRONIZADO = "N"'));
    print(citizenUpdate.length);
    // List list = await db.rawQuery('SELECT * FROM CIDADAOS WHERE CNS = $CNS');
    setState(() {});
  }

  @override
  void initState() {
    super.initState();
    getData();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBarDefault().appbar(context, 'RKM AB - Lista Atendimentos',widget.username),
      body: Container(
        decoration: ConstVariable().backgroundGradient,
        width: double.infinity,
        height: double.infinity,
        child: ListView(
          children: [
            Container(
              padding: ConstVariable().marginHightInput,
              color: ColorPalette.white,
              child: Column(
                children: [
                  TextDefault(
                    text: 'Atendimentos Domiciliares: ${serviceHome.length} | Visitas Domiciliares: ${visitHome.length}',
                    fontWeigth: FontWeight.bold,
                    color: ColorPalette.black54,
                    fontSize: 18,
                  ),
                  // TextDefault(
                  //   text: 'Atendimentos Odontológicos: 0 | Avaliação Elegibilidade: 0',
                  //   fontWeigth: FontWeight.bold,
                  //   color: ColorPalette.black54,
                  //   fontSize: 18,
                  // ),
                  TextDefault(
                    text: 'Cadastros Cidadãos Realizados / Atualizados : ${citizenUpdate.length}',
                    fontWeigth: FontWeight.bold,
                    color: ColorPalette.black54,
                    fontSize: 18,
                  ),
                  // TextDefault(
                  //   text: 'Fichas Complementares: 0 | Marcadores de Consumo : 0',
                  //   fontWeigth: FontWeight.bold,
                  //   color: ColorPalette.black54,
                  //   fontSize: 18,
                  // ),
                  // TextDefault(
                  //   text: 'Procedimentos Consolidados: 0 | Procedimentos Individuais : 0',
                  //   fontWeigth: FontWeight.bold,
                  //   color: ColorPalette.black54,
                  //   fontSize: 18,
                  // ),
                  // TextDefault(
                  //   text: 'Visitas Domiciliares: ${visitHome.length}',
                  //   fontWeigth: FontWeight.bold,
                  //   color: ColorPalette.black54,
                  //   fontSize: 18,
                  // ),
                ],
              )
            ),
          ],
        ),
      ),
    );
  }
}
