import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; class LeaveApplicationScreen extends StatefulWidget { const LeaveApplicationScreen({Key? key}) : super(key: key); @override State createState() => _LeaveApplicationScreenState(); } class _LeaveApplicationScreenState extends State { final TextEditingController _reasonController = TextEditingController(); DateTime? _startDate; DateTime? _endDate; Future _pickDate({required bool isStart}) async { final DateTime? picked = await showDatePicker( context: context, initialDate: DateTime.now(), firstDate: DateTime(2020), lastDate: DateTime(2100), ); if (picked != null) { setState(() { if (isStart) { _startDate = picked; } else { _endDate = picked; } }); } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( automaticallyImplyLeading: false, backgroundColor: Colors.white, title: Row( children: [ InkResponse( onTap: () => Navigator.pop(context, true), child: SvgPicture.asset( "assets/svg/appbar_back_button.svg", height: 25, ), ), const SizedBox(width: 10), const Text( "Leave Application", style: TextStyle( fontSize: 18, fontFamily: "Plus Jakarta Sans", fontWeight: FontWeight.w600, color: Colors.black87, ), ), ], ), ), body: Padding( padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Align( alignment: Alignment.topRight, child: Text( "Dummy Screen !", style: TextStyle( fontSize: 10, height: 1, fontWeight: FontWeight.bold, ), ), ), const Text( "Apply for Leave", style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, ), ), const SizedBox(height: 20), TextField( controller: _reasonController, decoration: const InputDecoration( labelText: "Reason for Leave", border: OutlineInputBorder(), ), maxLines: 3, ), const SizedBox(height: 20), Row( children: [ Expanded( child: ElevatedButton( onPressed: () => _pickDate(isStart: true), child: Text(_startDate == null ? "Select Start Date" : "Start: ${_startDate!.toLocal()}".split(' ')[0]), ), ), const SizedBox(width: 10), Expanded( child: ElevatedButton( onPressed: () => _pickDate(isStart: false), child: Text(_endDate == null ? "Select End Date" : "End: ${_endDate!.toLocal()}".split(' ')[0]), ), ), ], ), const Spacer(), SizedBox( width: double.infinity, child: ElevatedButton( onPressed: () { // Handle submission logic here ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text("Leave application submitted")), ); }, child: const Text("Submit Application"), ), ), ], ), ), ); } }