-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.dart
110 lines (102 loc) · 3.45 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import 'package:flutter/material.dart';
// import 'package:horizontal_week_calendar/horizontal_week_calendar.dart';
import 'package:intl/intl.dart';
import 'package:packages_test/horizotal_week_calendar/horizontal_week_calendar.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Packages Test',
theme: ThemeData(
primarySwatch: Colors.deepPurple,
),
home: const HorizontalWeekCalendarPackage(),
debugShowCheckedModeBanner: false,
);
}
}
class HorizontalWeekCalendarPackage extends StatefulWidget {
const HorizontalWeekCalendarPackage({super.key});
@override
State<HorizontalWeekCalendarPackage> createState() =>
_HorizontalWeekCalendarPackageState();
}
class _HorizontalWeekCalendarPackageState
extends State<HorizontalWeekCalendarPackage> {
var selectedDate = DateTime.now();
@override
Widget build(BuildContext context) {
var theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.deepPurple,
title: const Text(
"Horizontal Week Calendar",
style: TextStyle(
color: Colors.white,
),
),
),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(10),
child: Column(
children: [
HorizontalWeekCalendar(
minDate: DateTime(2023, 12, 31),
maxDate: DateTime(2024, 1, 31),
initialDate: DateTime(2024, 1, 15),
onDateChange: (date) {
setState(() {
selectedDate = date;
});
},
showTopNavbar: false,
monthFormat: "MMMM yyyy",
showNavigationButtons: true,
weekStartFrom: WeekStartFrom.Monday,
borderRadius: BorderRadius.circular(7),
activeBackgroundColor: Colors.deepPurple,
activeTextColor: Colors.white,
inactiveBackgroundColor: Colors.deepPurple.withOpacity(.3),
inactiveTextColor: Colors.white,
disabledTextColor: Colors.grey,
disabledBackgroundColor: Colors.grey.withOpacity(.3),
activeNavigatorColor: Colors.deepPurple,
inactiveNavigatorColor: Colors.grey,
monthColor: Colors.deepPurple,
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"Selected Date",
textAlign: TextAlign.center,
style: theme.textTheme.titleMedium!.copyWith(
color: theme.primaryColor,
),
),
const SizedBox(height: 3),
Text(
DateFormat('dd MMM yyyy').format(selectedDate),
textAlign: TextAlign.center,
style: theme.textTheme.titleLarge!.copyWith(
color: theme.primaryColor,
),
),
],
),
),
],
),
),
),
);
}
}