Skip to content

Commit

Permalink
Merge pull request #65 from ViktorKirjanov/feature/add-more-configura…
Browse files Browse the repository at this point in the history
…tion

Feature: add more configuration, fix overflow
  • Loading branch information
muhammadtalhasultan authored Jul 3, 2024
2 parents 9496ed1 + 01f1d85 commit 2d5a7a1
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 26 deletions.
11 changes: 9 additions & 2 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.17.0"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
lints:
dependency: transitive
description:
Expand All @@ -93,7 +101,6 @@ packages:
matcher:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
Expand Down Expand Up @@ -200,5 +207,5 @@ packages:
source: hosted
version: "0.1.4-beta"
sdks:
dart: ">=3.1.0-185.0.dev <4.0.0"
dart: ">=3.0.0-0 <4.0.0"
flutter: ">=2.12.0"
26 changes: 25 additions & 1 deletion lib/src/calendar_timeline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ class CalendarTimeline extends StatefulWidget {
this.monthColor,
this.dotsColor,
this.dayNameColor,
this.height = 80,
this.width = 60,
this.shrinkHeight = 50,
this.shrinkWidth = 33,
this.fontSize = 32,
this.shrinkFontSize = 14,
this.dayNameFontSize = 14,
this.shrinkDayNameFontSize = 9,
this.shrink = false,
this.locale,
this.showYears = false,
Expand Down Expand Up @@ -64,6 +72,14 @@ class CalendarTimeline extends StatefulWidget {
final Color? monthColor;
final Color? dotsColor;
final Color? dayNameColor;
final double height;
final double width;
final double shrinkHeight;
final double shrinkWidth;
final double fontSize;
final double shrinkFontSize;
final double dayNameFontSize;
final double shrinkDayNameFontSize;
final bool shrink;
final String? locale;

Expand Down Expand Up @@ -430,7 +446,7 @@ class _CalendarTimelineState extends State<CalendarTimeline> {
Widget _buildDayList() {
return SizedBox(
key: const Key('ScrollableDayList'),
height: 70,
height: widget.shrink ? widget.shrinkHeight : widget.height,
child: ScrollablePositionedList.builder(
itemScrollController: _controllerDay,
initialScrollIndex: _daySelectedIndex ?? 0,
Expand Down Expand Up @@ -458,6 +474,14 @@ class _CalendarTimelineState extends State<CalendarTimeline> {
activeDayBackgroundColor: widget.activeBackgroundDayColor,
dotsColor: widget.dotsColor,
dayNameColor: widget.dayNameColor,
height: widget.height,
width: widget.width,
shrinkHeight: widget.shrinkHeight,
shrinkWidth: widget.shrinkWidth,
fontSize: widget.fontSize,
shrinkFontSize: widget.shrinkFontSize,
dayNameFontSize: widget.dayNameFontSize,
shrinkDayNameFontSize: widget.shrinkDayNameFontSize,
shrink: widget.shrink,
),
if (index == _days.length - 1)
Expand Down
63 changes: 45 additions & 18 deletions lib/src/day_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ class DayItem extends StatelessWidget {
this.available = true,
this.dotsColor,
this.dayNameColor,
required this.height,
required this.width,
required this.shrinkHeight,
required this.shrinkWidth,
required this.fontSize,
required this.shrinkFontSize,
required this.dayNameFontSize,
required this.shrinkDayNameFontSize,
this.shrink = false,
}) : super(key: key);
final int dayNumber;
Expand All @@ -26,6 +34,14 @@ class DayItem extends StatelessWidget {
final bool available;
final Color? dotsColor;
final Color? dayNameColor;
final double height;
final double width;
final double shrinkHeight;
final double shrinkWidth;
final double fontSize;
final double shrinkFontSize;
final double dayNameFontSize;
final double shrinkDayNameFontSize;
final bool shrink;

GestureDetector _buildDay(BuildContext context) {
Expand All @@ -34,12 +50,12 @@ class DayItem extends StatelessWidget {
? dayColor ?? Theme.of(context).colorScheme.secondary
: dayColor?.withOpacity(0.5) ??
Theme.of(context).colorScheme.secondary.withOpacity(0.5),
fontSize: shrink ? 14 : 32,
fontWeight: FontWeight.normal,
fontSize: shrink ? shrinkFontSize : fontSize,
height: 0.8,
);
final selectedStyle = TextStyle(
color: activeDayColor ?? Colors.white,
fontSize: shrink ? 14 : 32,
fontSize: shrink ? shrinkFontSize : fontSize,
fontWeight: FontWeight.bold,
height: 0.8,
);
Expand All @@ -54,29 +70,40 @@ class DayItem extends StatelessWidget {
borderRadius: BorderRadius.circular(12),
)
: const BoxDecoration(color: Colors.transparent),
height: shrink ? 40 : 70,
width: shrink ? 33 : 60,
height: shrink ? shrinkHeight : height,
width: shrink ? shrinkWidth : width,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
if (isSelected) ...[
SizedBox(height: shrink ? 6 : 7),
if (!shrink) _buildDots(),
SizedBox(height: shrink ? 9 : 12),
] else
SizedBox(height: shrink ? 10 : 14),
Text(
dayNumber.toString(),
style: isSelected ? selectedStyle : textStyle,
),
if (isSelected)
Text(
Column(
children: [
SizedBox(height: shrink ? 6 : 7),
if (!shrink) _buildDots(),
SizedBox(height: shrink ? 6 : 7),
],
)
else
SizedBox(height: shrink ? 12 : 19),
Center(
child: Text(
dayNumber.toString(),
style: isSelected ? selectedStyle : textStyle,
),
),
Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Text(
shortName,
style: TextStyle(
color: dayNameColor ?? activeDayColor ?? Colors.white,
color: isSelected
? dayNameColor ?? activeDayColor ?? Colors.white
: Colors.transparent,
fontWeight: FontWeight.bold,
fontSize: shrink ? 9 : 14,
fontSize: shrink ? shrinkDayNameFontSize : dayNameFontSize,
),
),
),
],
),
),
Expand Down
18 changes: 13 additions & 5 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.18.1"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
matcher:
dependency: transitive
description:
Expand All @@ -79,7 +87,7 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
url: "https://pub.dev"
source: hosted
version: "0.5.0"
Expand Down Expand Up @@ -116,7 +124,7 @@ packages:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
url: "https://pub.dev"
source: hosted
version: "1.10.0"
Expand Down Expand Up @@ -156,10 +164,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.5.1"
vector_math:
dependency: transitive
description:
Expand All @@ -185,5 +193,5 @@ packages:
source: hosted
version: "0.1.4-beta"
sdks:
dart: ">=3.1.0-185.0.dev <4.0.0"
dart: ">=3.0.0-0 <4.0.0"
flutter: ">=2.12.0"
40 changes: 40 additions & 0 deletions test/src/day_item_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ void main() {
dayNumber: ParamFactory.dayNumber,
shortName: ParamFactory.dayName,
isSelected: true,
height: 70,
width: 60,
shrinkHeight: 40,
shrinkWidth: 33,
fontSize: 32,
shrinkFontSize: 14,
dayNameFontSize: 14,
shrinkDayNameFontSize: 9,
onTap: () {},
),
);
Expand All @@ -42,6 +50,14 @@ void main() {
dayNumber: ParamFactory.dayNumber,
shortName: ParamFactory.dayName,
activeDayBackgroundColor: ParamFactory.activeColor,
height: 70,
width: 60,
shrinkHeight: 40,
shrinkWidth: 33,
fontSize: 32,
shrinkFontSize: 14,
dayNameFontSize: 14,
shrinkDayNameFontSize: 9,
onTap: () {},
),
);
Expand All @@ -61,6 +77,14 @@ void main() {
shortName: ParamFactory.dayName,
activeDayBackgroundColor: ParamFactory.activeColor,
isSelected: true,
height: 70,
width: 60,
shrinkHeight: 40,
shrinkWidth: 33,
fontSize: 32,
shrinkFontSize: 14,
dayNameFontSize: 14,
shrinkDayNameFontSize: 9,
onTap: () {},
),
);
Expand All @@ -83,6 +107,14 @@ void main() {
dayNumber: ParamFactory.dayNumber,
shortName: ParamFactory.dayName,
activeDayColor: ParamFactory.activeColor,
height: 70,
width: 60,
shrinkHeight: 40,
shrinkWidth: 33,
fontSize: 32,
shrinkFontSize: 14,
dayNameFontSize: 14,
shrinkDayNameFontSize: 9,
onTap: () {},
),
);
Expand All @@ -102,6 +134,14 @@ void main() {
shortName: ParamFactory.dayName,
activeDayColor: ParamFactory.activeColor,
isSelected: true,
height: 70,
width: 60,
shrinkHeight: 40,
shrinkWidth: 33,
fontSize: 32,
shrinkFontSize: 14,
dayNameFontSize: 14,
shrinkDayNameFontSize: 9,
onTap: () {},
),
);
Expand Down

0 comments on commit 2d5a7a1

Please sign in to comment.