import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:unit2/model/profile/references.dart';
import 'package:unit2/theme-data.dart/box_shadow.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/add_leading.dart';
import 'package:unit2/widgets/empty_data.dart';

class ReferencesScreen extends StatelessWidget {
  final List<PersonalReference> references;
  const ReferencesScreen({super.key, required this.references});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(referencesScreenTitle),
        centerTitle: true,
        backgroundColor: primary,
        actions: [AddLeading(onPressed: (){})],
      ),
      body: references.isNotEmpty? ListView.builder(
          padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
          itemCount: references.length,
          itemBuilder: (BuildContext context, int index) {
            String fullname =
                "${references[index].firstName} ${references[index].middleName} ${references[index].lastName}";
            String addres =
                "${references[index].address!.cityMunicipality!.description}, ${references[index].address!.cityMunicipality!.province!.description}, ${references[0].address!.cityMunicipality!.province!.region!.description}";
            String mobile = references[index].contactNo.toString();
            return Column(
              children: [
                Container(
                  padding:
                      const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
                  decoration: box1(),
                  child: Row(
                    children: [
                      Expanded(
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.start,
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Text(fullname,
                                style: Theme.of(context)
                                    .textTheme
                                    .titleMedium!
                                    .copyWith(fontWeight: FontWeight.w500)),
                            const Divider(),
                            const SizedBox(
                              height: 5,
                            ),
                            Text(addres,
                                style: Theme.of(context)
                                    .textTheme
                                    .titleSmall!
                                    .copyWith(fontWeight: FontWeight.w500)),
                            const SizedBox(
                              height: 8,
                            ),
                            Text("${mobileOrPhone.toUpperCase()} : $mobile",
                                style:
                                    Theme.of(context).textTheme.labelMedium!),
                          ],
                        ),
                      ),
                      IconButton(
                          onPressed: () {},
                          icon: const Icon(
                            Icons.more_vert,
                            color: Colors.grey,
                          ))
                    ],
                  ),
                ),
                const SizedBox(
                  height: 5,
                ),
              ],
            );
          }):const EmptyData(message: "You don't have any References added. Please click + to add."),
    );
  }
}
