import 'package:flutter/material.dart';
import 'package:unit2/model/profile/basic_information/identification_information.dart';
import 'package:unit2/theme-data.dart/box_shadow.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/add_leading.dart';
import 'package:unit2/widgets/empty_data.dart';

class IdentificationsScreen extends StatelessWidget {
  final List<Identification> identities;
  const IdentificationsScreen({super.key, required this.identities});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(identificationScreenTitle),
        centerTitle: true,
        backgroundColor: primary,
        actions: [AddLeading(onPressed: (){})],
      ),
      body:identities.isNotEmpty? ListView.builder(
          padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
          itemCount: identities.length,
          itemBuilder: (BuildContext context, int index) {
            String agency = identities[index].agency!.name!;
            String idNumber =  identities[index].identificationNumber!;
            bool government =  identities[index].agency!.privateEntity!;
            String issuedAt =   "${identities[index].issuedAt!.cityMunicipality!.description!} ${identities[index].issuedAt!.cityMunicipality!.province!.description}";
            return Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Container(
                  width: screenWidth,
                  decoration: box1(),
                  padding:
                      const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
                  child: Row(
                    children: [
                      Expanded(
                        child: Column(
                            mainAxisAlignment: MainAxisAlignment.start,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Text(agency,style: Theme.of(context).textTheme.titleMedium!.copyWith(fontWeight: FontWeight.w500)),
                              const Divider(),
                              const SizedBox(height: 5,),
                              Row(
                                children: [
                                  Expanded(
                                    child: Text(
                                      "$idNumberText : $idNumber",style: Theme.of(context).textTheme.titleSmall,
                                      ),
                                  ),
                               
                                  Badge(
                            
                                      backgroundColor: success2,
                                      label: Text(
                                       government ==
                                                true
                                            ? privateText.toUpperCase()
                                            :governmentText.toUpperCase(),
                                      style: Theme.of(context).textTheme.bodySmall!.copyWith(color: Colors.white),)),
                                ],
                              ),
                              const SizedBox(height: 5,),
                              Text(issuedAt),
                            ]),
                      ),
                      IconButton(
                          onPressed: () {}, icon: const Icon(Icons.more_vert,color: Colors.grey,))
                    ],
                  ),
                ),
                const SizedBox(
                  height: 5,
                ),
              ],
            );
          }):const EmptyData(message: "You don't have identifications added. Please click + to add."),
    );
  }
}
