import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:intl/intl.dart';
import 'package:unit2/model/profile/learning_development.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 LearningAndDevelopmentScreen extends StatelessWidget {
  final List<LearningDevelopement> learningDevelopments;
  const LearningAndDevelopmentScreen({super.key, required this.learningDevelopments});

   

  @override
  Widget build(BuildContext context) {
       DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
    return  Scaffold(
      appBar: AppBar(title: const Text(learningAndDevelopmentScreenTitle),
      centerTitle: true,
      backgroundColor: primary,
      actions: [AddLeading(onPressed: (){})],
      ),
      body: learningDevelopments.isNotEmpty? ListView.builder(
              padding: const EdgeInsets.symmetric(vertical: 8,horizontal: 10),
        itemCount: learningDevelopments.length,
        itemBuilder: (BuildContext context, int index){
          String training = learningDevelopments[index].conductedTraining!.title!.title!;
          String provider = learningDevelopments[index].conductedTraining!.conductedBy!.name!;
          String start = dteFormat2.format(learningDevelopments[index].conductedTraining!.fromDate!);
          String end = dteFormat2.format(learningDevelopments[index].conductedTraining!.toDate!);
          String type = learningDevelopments[index].conductedTraining!.learningDevelopmentType!.title!;
          return Column(
            children: [
              Container(
                     decoration: box1(),
              padding: const EdgeInsets.symmetric(horizontal: 12,vertical: 8),
                width: screenWidth,
                child: Row(
                  children: [
                    Expanded(
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.start,
                                  crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                        Text(training,style: Theme.of(context).textTheme.titleMedium!.copyWith(fontWeight: FontWeight.w500),),
                       const Divider(),
                        const SizedBox(height: 5,),
                        Text(provider,style: Theme.of(context).textTheme.titleSmall,),
                        const SizedBox(height: 5,),
                        Text("$duration : $start TO $end",style: Theme.of(context).textTheme.labelMedium,),
                        const SizedBox(height: 5,),
                        Text("$type : $type",style: Theme.of(context).textTheme.labelMedium,),
                      ]),
                    ),
                       IconButton(onPressed: (){}, icon: const Icon(Icons.more_vert)),
                  ],
                ),
              ),
              const SizedBox(height: 8,),
            ],
          );
      }):const EmptyData(message: "You don't have any Learning and Development added. Please click + to add."),
    );
  }
}