From 77b09992f052ed265ccdc10d1bce99900a9ef997 Mon Sep 17 00:00:00 2001 From: Process-ing Date: Wed, 11 Sep 2024 22:12:55 +0100 Subject: [PATCH 01/13] Create Calendar widget --- packages/uni_ui/lib/calendar/calendar.dart | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 packages/uni_ui/lib/calendar/calendar.dart diff --git a/packages/uni_ui/lib/calendar/calendar.dart b/packages/uni_ui/lib/calendar/calendar.dart new file mode 100644 index 000000000..a92bad40c --- /dev/null +++ b/packages/uni_ui/lib/calendar/calendar.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class Calendar extends StatelessWidget { + const Calendar({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return ListView( + scrollDirection: Axis.horizontal, + children: [ + Text('FEUP Project Week'), + ], + ); + } +} \ No newline at end of file From eb0e93d7639d32889b646d2ee0bfb56479e0bfd7 Mon Sep 17 00:00:00 2001 From: Process-ing Date: Wed, 2 Oct 2024 08:36:31 +0100 Subject: [PATCH 02/13] Create CalendarItem --- packages/uni_ui/lib/calendar/calendar.dart | 17 ++++++---- .../uni_ui/lib/calendar/calendar_item.dart | 31 +++++++++++++++++++ 2 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 packages/uni_ui/lib/calendar/calendar_item.dart diff --git a/packages/uni_ui/lib/calendar/calendar.dart b/packages/uni_ui/lib/calendar/calendar.dart index a92bad40c..ed1028f21 100644 --- a/packages/uni_ui/lib/calendar/calendar.dart +++ b/packages/uni_ui/lib/calendar/calendar.dart @@ -1,15 +1,20 @@ import 'package:flutter/material.dart'; +import 'package:uni_ui/calendar/calendar_item.dart'; class Calendar extends StatelessWidget { - const Calendar({Key? key}) : super(key: key); + const Calendar({ + Key? key, + required this.items, + }) : super(key: key); + + final List items; @override Widget build(BuildContext context) { - return ListView( - scrollDirection: Axis.horizontal, - children: [ - Text('FEUP Project Week'), - ], + return SingleChildScrollView( + child: Row( + children: items, + ), ); } } \ No newline at end of file diff --git a/packages/uni_ui/lib/calendar/calendar_item.dart b/packages/uni_ui/lib/calendar/calendar_item.dart new file mode 100644 index 000000000..093cb247a --- /dev/null +++ b/packages/uni_ui/lib/calendar/calendar_item.dart @@ -0,0 +1,31 @@ +import 'package:flutter/material.dart'; + +class CalendarItem extends StatelessWidget { + const CalendarItem({ + super.key, + required this.date, + required this.title, + }); + + final String date; + final String title; + + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.all(10), + padding: const EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.25), + blurRadius: 6, + ), + ], + ), + child: Text(this.title), + ); + } +} \ No newline at end of file From 0d9025db42f68d132d5f5ce7b6bd17e421713214 Mon Sep 17 00:00:00 2001 From: Process-ing Date: Tue, 22 Oct 2024 15:41:54 +0100 Subject: [PATCH 03/13] Design calendar item interior --- .../uni_ui/lib/calendar/calendar_item.dart | 31 +- packages/uni_ui/lib/main.dart | 329 ------------------ 2 files changed, 20 insertions(+), 340 deletions(-) delete mode 100644 packages/uni_ui/lib/main.dart diff --git a/packages/uni_ui/lib/calendar/calendar_item.dart b/packages/uni_ui/lib/calendar/calendar_item.dart index 093cb247a..0f506f03d 100644 --- a/packages/uni_ui/lib/calendar/calendar_item.dart +++ b/packages/uni_ui/lib/calendar/calendar_item.dart @@ -1,3 +1,4 @@ +import 'package:figma_squircle/figma_squircle.dart'; import 'package:flutter/material.dart'; class CalendarItem extends StatelessWidget { @@ -14,18 +15,26 @@ class CalendarItem extends StatelessWidget { Widget build(BuildContext context) { return Container( margin: const EdgeInsets.all(10), - padding: const EdgeInsets.all(10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(20), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.25), - blurRadius: 6, - ), - ], + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 15), + width: 140, + decoration: ShapeDecoration( + color: Theme.of(context).colorScheme.secondary, + shape: SmoothRectangleBorder( + borderRadius: SmoothBorderRadius( + cornerRadius: 15, + cornerSmoothing: 1, + ) + ) + ), + child: Text( + this.title, + style: TextStyle( + color: Theme.of(context).colorScheme.primary, + fontSize: 16, + fontWeight: FontWeight.w500, + height: 1, + ), ), - child: Text(this.title), ); } } \ No newline at end of file diff --git a/packages/uni_ui/lib/main.dart b/packages/uni_ui/lib/main.dart deleted file mode 100644 index fc1d906a2..000000000 --- a/packages/uni_ui/lib/main.dart +++ /dev/null @@ -1,329 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:uni_ui/timeline/timeline.dart'; - -void main() { - runApp(MyApp()); -} - -class MyApp extends StatelessWidget { - @override - Widget build(BuildContext context) { - return MaterialApp( - theme: ThemeData.light(), - home: Scaffold( - appBar: AppBar( - title: Text('Timeline Example'), - ), - body: Timeline( - content: [ - Container( - color: Colors.red[100], - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Content for Tab 1', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), - ), - SizedBox(height: 8), - Text( - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' - 'Suspendisse eget tincidunt sapien. Phasellus sed ligula id ' - 'turpis vulputate efficitur. Donec ut arcu vel leo blandit ' - 'dictum. Cras ut massa nisi. Nulla facilisi. Quisque porta ' - 'lobortis diam, at interdum orci.', - style: TextStyle(fontSize: 16), - ), - SizedBox(height: 16), - Text( - 'Sed ut perspiciatis unde omnis iste natus error sit voluptatem ' - 'accusantium doloremque laudantium, totam rem aperiam, eaque ' - 'ipsa quae ab illo inventore veritatis et quasi architecto ' - 'beatae vitae dicta sunt explicabo.', - style: TextStyle(fontSize: 16), - ), - SizedBox(height: 16), - Text( - 'At vero eos et accusamus et iusto odio dignissimos ducimus ' - 'qui blanditiis praesentium voluptatum deleniti atque corrupti ' - 'quos dolores et quas molestias excepturi sint occaecati ' - 'cupiditate non provident.', - style: TextStyle(fontSize: 16), - ), - ], - ), - ), - Container( - color: Colors.green[100], - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Content for Tab 2', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), - ), - SizedBox(height: 8), - Text( - 'Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut ' - 'odit aut fugit, sed quia consequuntur magni dolores eos qui ' - 'ratione voluptatem sequi nesciunt.', - style: TextStyle(fontSize: 16), - ), - SizedBox(height: 16), - Text( - 'Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, ' - 'consectetur, adipisci velit, sed quia non numquam eius modi ' - 'tempora incidunt ut labore et dolore magnam aliquam quaerat ' - 'voluptatem.', - style: TextStyle(fontSize: 16), - ), - SizedBox(height: 16), - Text( - 'Ut enim ad minima veniam, quis nostrum exercitationem ullam ' - 'corporis suscipit laboriosam, nisi ut aliquid ex ea commodi ' - 'consequatur?', - style: TextStyle(fontSize: 16), - ), - ], - ), - ), - Container( - color: Colors.blue[100], - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Content for Tab 3', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), - ), - SizedBox(height: 8), - Text( - 'Quis autem vel eum iure reprehenderit qui in ea voluptate ' - 'velit esse quam nihil molestiae consequatur, vel illum qui ' - 'dolorem eum fugiat quo voluptas nulla pariatur?', - style: TextStyle(fontSize: 16), - ), - SizedBox(height: 16), - Text( - 'But I must explain to you how all this mistaken idea of ' - 'denouncing pleasure and praising pain was born and I will ' - 'give you a complete account of the system, and expound the ' - 'actual teachings of the great explorer of the truth.', - style: TextStyle(fontSize: 16), - ), - SizedBox(height: 16), - Text( - 'Nor again is there anyone who loves or pursues or desires to ' - 'obtain pain of itself, because it is pain, but because ' - 'occasionally circumstances occur in which toil and pain can ' - 'procure him some great pleasure.', - style: TextStyle(fontSize: 16), - ), - ], - ), - ), - Container( - color: Colors.red[100], - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Content for Tab 4', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), - ), - SizedBox(height: 8), - Text( - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' - 'Suspendisse eget tincidunt sapien. Phasellus sed ligula id ' - 'turpis vulputate efficitur. Donec ut arcu vel leo blandit ' - 'dictum. Cras ut massa nisi. Nulla facilisi. Quisque porta ' - 'lobortis diam, at interdum orci.', - style: TextStyle(fontSize: 16), - ), - SizedBox(height: 16), - Text( - 'Sed ut perspiciatis unde omnis iste natus error sit voluptatem ' - 'accusantium doloremque laudantium, totam rem aperiam, eaque ' - 'ipsa quae ab illo inventore veritatis et quasi architecto ' - 'beatae vitae dicta sunt explicabo.', - style: TextStyle(fontSize: 16), - ), - SizedBox(height: 16), - Text( - 'At vero eos et accusamus et iusto odio dignissimos ducimus ' - 'qui blanditiis praesentium voluptatum deleniti atque corrupti ' - 'quos dolores et quas molestias excepturi sint occaecati ' - 'cupiditate non provident.', - style: TextStyle(fontSize: 16), - ), - ], - ), - ), - Container( - color: Colors.red[100], - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Content for Tab 5', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), - ), - SizedBox(height: 8), - Text( - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' - 'Suspendisse eget tincidunt sapien. Phasellus sed ligula id ' - 'turpis vulputate efficitur. Donec ut arcu vel leo blandit ' - 'dictum. Cras ut massa nisi. Nulla facilisi. Quisque porta ' - 'lobortis diam, at interdum orci.', - style: TextStyle(fontSize: 16), - ), - SizedBox(height: 16), - Text( - 'Sed ut perspiciatis unde omnis iste natus error sit voluptatem ' - 'accusantium doloremque laudantium, totam rem aperiam, eaque ' - 'ipsa quae ab illo inventore veritatis et quasi architecto ' - 'beatae vitae dicta sunt explicabo.', - style: TextStyle(fontSize: 16), - ), - SizedBox(height: 16), - Text( - 'At vero eos et accusamus et iusto odio dignissimos ducimus ' - 'qui blanditiis praesentium voluptatum deleniti atque corrupti ' - 'quos dolores et quas molestias excepturi sint occaecati ' - 'cupiditate non provident.', - style: TextStyle(fontSize: 16), - ), - ], - ), - ), - Container( - color: Colors.red[100], - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Content for Tab 6', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), - ), - SizedBox(height: 8), - Text( - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' - 'Suspendisse eget tincidunt sapien. Phasellus sed ligula id ' - 'turpis vulputate efficitur. Donec ut arcu vel leo blandit ' - 'dictum. Cras ut massa nisi. Nulla facilisi. Quisque porta ' - 'lobortis diam, at interdum orci.', - style: TextStyle(fontSize: 16), - ), - SizedBox(height: 16), - Text( - 'Sed ut perspiciatis unde omnis iste natus error sit voluptatem ' - 'accusantium doloremque laudantium, totam rem aperiam, eaque ' - 'ipsa quae ab illo inventore veritatis et quasi architecto ' - 'beatae vitae dicta sunt explicabo.', - style: TextStyle(fontSize: 16), - ), - SizedBox(height: 16), - Text( - 'At vero eos et accusamus et iusto odio dignissimos ducimus ' - 'qui blanditiis praesentium voluptatum deleniti atque corrupti ' - 'quos dolores et quas molestias excepturi sint occaecati ' - 'cupiditate non provident.', - style: TextStyle(fontSize: 16), - ), - ], - ), - ), - Container( - color: Colors.red[100], - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Content for Tab 7', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), - ), - SizedBox(height: 8), - Text( - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' - 'Suspendisse eget tincidunt sapien. Phasellus sed ligula id ' - 'turpis vulputate efficitur. Donec ut arcu vel leo blandit ' - 'dictum. Cras ut massa nisi. Nulla facilisi. Quisque porta ' - 'lobortis diam, at interdum orci.', - style: TextStyle(fontSize: 16), - ), - SizedBox(height: 16), - Text( - 'Sed ut perspiciatis unde omnis iste natus error sit voluptatem ' - 'accusantium doloremque laudantium, totam rem aperiam, eaque ' - 'ipsa quae ab illo inventore veritatis et quasi architecto ' - 'beatae vitae dicta sunt explicabo.', - style: TextStyle(fontSize: 16), - ), - SizedBox(height: 16), - Text( - 'At vero eos et accusamus et iusto odio dignissimos ducimus ' - 'qui blanditiis praesentium voluptatum deleniti atque corrupti ' - 'quos dolores et quas molestias excepturi sint occaecati ' - 'cupiditate non provident.', - style: TextStyle(fontSize: 16), - ), - ], - ), - ), - ], - tabs: [ - Column( - children: [ - Text('Mon'), - Text('1'), - ], - ), - Column( - children: [ - Text('Tue'), - Text('2'), - ], - ), - Column( - children: [ - Text('Wed'), - Text('3'), - ], - ), - Column( - children: [ - Text('Thu'), - Text('4'), - ], - ), - Column( - children: [ - Text('Fri'), - Text('5'), - ], - ), - Column( - children: [ - Text('Sat'), - Text('6'), - ], - ), - Column( - children: [ - Text('Sun'), - Text('7'), - ], - ), - ], - ), - ), - ); - } -} From bb17ebd99b9512a3200b9796fb5132c458e5e9a4 Mon Sep 17 00:00:00 2001 From: Process-ing Date: Tue, 22 Oct 2024 15:51:22 +0100 Subject: [PATCH 04/13] Add shadow to calendar item --- packages/uni_ui/lib/calendar/calendar_item.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/uni_ui/lib/calendar/calendar_item.dart b/packages/uni_ui/lib/calendar/calendar_item.dart index 0f506f03d..225fbe2e8 100644 --- a/packages/uni_ui/lib/calendar/calendar_item.dart +++ b/packages/uni_ui/lib/calendar/calendar_item.dart @@ -21,10 +21,16 @@ class CalendarItem extends StatelessWidget { color: Theme.of(context).colorScheme.secondary, shape: SmoothRectangleBorder( borderRadius: SmoothBorderRadius( - cornerRadius: 15, + cornerRadius: 12, cornerSmoothing: 1, + ), + ), + shadows: [ + BoxShadow( + color: Theme.of(context).colorScheme.shadow.withAlpha(0x3f), + blurRadius: 6, ) - ) + ] ), child: Text( this.title, From 38786279036803284af80945a9aecb50a8381e2e Mon Sep 17 00:00:00 2001 From: Process-ing Date: Sat, 26 Oct 2024 11:32:44 +0100 Subject: [PATCH 05/13] Add circle above calendar item --- .../uni_ui/lib/calendar/calendar_item.dart | 65 ++++++++++++------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/packages/uni_ui/lib/calendar/calendar_item.dart b/packages/uni_ui/lib/calendar/calendar_item.dart index 225fbe2e8..90c337e35 100644 --- a/packages/uni_ui/lib/calendar/calendar_item.dart +++ b/packages/uni_ui/lib/calendar/calendar_item.dart @@ -13,34 +13,49 @@ class CalendarItem extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - margin: const EdgeInsets.all(10), - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 15), - width: 140, - decoration: ShapeDecoration( - color: Theme.of(context).colorScheme.secondary, - shape: SmoothRectangleBorder( - borderRadius: SmoothBorderRadius( - cornerRadius: 12, - cornerSmoothing: 1, + return Column( + children: [ + Container( + width: 20, + height: 20, + decoration: BoxDecoration( + shape: BoxShape.circle, + border: Border.all( + color: Theme.of(context).colorScheme.primary, + width: 4.0, + ) ), ), - shadows: [ - BoxShadow( - color: Theme.of(context).colorScheme.shadow.withAlpha(0x3f), - blurRadius: 6, - ) - ] - ), - child: Text( - this.title, - style: TextStyle( - color: Theme.of(context).colorScheme.primary, - fontSize: 16, - fontWeight: FontWeight.w500, - height: 1, + Container( + margin: const EdgeInsets.all(10), + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 15), + width: 140, + decoration: ShapeDecoration( + color: Theme.of(context).colorScheme.secondary, + shape: SmoothRectangleBorder( + borderRadius: SmoothBorderRadius( + cornerRadius: 12, + cornerSmoothing: 1, + ), + ), + shadows: [ + BoxShadow( + color: Theme.of(context).colorScheme.shadow.withAlpha(0x3f), + blurRadius: 6, + ) + ] + ), + child: Text( + this.title, + style: TextStyle( + color: Theme.of(context).colorScheme.primary, + fontSize: 16, + fontWeight: FontWeight.w500, + height: 1, + ), + ), ), - ), + ], ); } } \ No newline at end of file From 50ebcf6ef73084841399dd154185e3a32cea8c39 Mon Sep 17 00:00:00 2001 From: Process-ing Date: Sat, 26 Oct 2024 15:03:37 +0100 Subject: [PATCH 06/13] Add date to calendar item and fix scroll --- packages/uni_ui/lib/calendar/calendar.dart | 3 +- .../uni_ui/lib/calendar/calendar_item.dart | 45 ++++++++++++++++--- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/packages/uni_ui/lib/calendar/calendar.dart b/packages/uni_ui/lib/calendar/calendar.dart index ed1028f21..255beb06b 100644 --- a/packages/uni_ui/lib/calendar/calendar.dart +++ b/packages/uni_ui/lib/calendar/calendar.dart @@ -12,7 +12,8 @@ class Calendar extends StatelessWidget { @override Widget build(BuildContext context) { return SingleChildScrollView( - child: Row( + scrollDirection: Axis.horizontal, + child: Row( // To avoid the widget from expanding vertically children: items, ), ); diff --git a/packages/uni_ui/lib/calendar/calendar_item.dart b/packages/uni_ui/lib/calendar/calendar_item.dart index 90c337e35..3bafcc5e1 100644 --- a/packages/uni_ui/lib/calendar/calendar_item.dart +++ b/packages/uni_ui/lib/calendar/calendar_item.dart @@ -4,18 +4,35 @@ import 'package:flutter/material.dart'; class CalendarItem extends StatelessWidget { const CalendarItem({ super.key, - required this.date, - required this.title, + required this.eventName, + required this.eventPeriod, }); - final String date; - final String title; + final String eventName; + final DateTimeRange eventPeriod; @override Widget build(BuildContext context) { return Column( + mainAxisSize: MainAxisSize.min, children: [ + Text( + parsePeriod(this.eventPeriod), + style: TextStyle( + fontSize: 15, + height: 1, + fontWeight: FontWeight.w500, + ), + ), + Text( + this.eventPeriod.end.year.toString(), + style: TextStyle( + color: Theme.of(context).colorScheme.outline, + fontSize: 11, + ), + ), Container( + margin: EdgeInsets.only(top: 5), width: 20, height: 20, decoration: BoxDecoration( @@ -46,7 +63,7 @@ class CalendarItem extends StatelessWidget { ] ), child: Text( - this.title, + this.eventName, style: TextStyle( color: Theme.of(context).colorScheme.primary, fontSize: 16, @@ -58,4 +75,22 @@ class CalendarItem extends StatelessWidget { ], ); } + + static String monthToString(int month) { + // TODO: Support English + const strMonths = ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dec"]; + return strMonths[month - 1]; + } + + static String parsePeriod(DateTimeRange period) { + final start = period.start, end = period.end; + + if (start.month == end.month) { + return start.day == end.day + ? "${start.day} ${monthToString(start.month)}." + : "${start.day}-${end.day} ${monthToString(start.month)}."; + } else { + return "${start.day} ${monthToString(start.month)}. - ${end.day} ${monthToString(end.month)}."; + } + } } \ No newline at end of file From 66ee2d63d0dff72d0faf07823420e6d0b685264d Mon Sep 17 00:00:00 2001 From: Process-ing Date: Sat, 26 Oct 2024 16:59:14 +0100 Subject: [PATCH 07/13] Add leg to calendar item circle --- .../uni_ui/lib/calendar/calendar_item.dart | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/packages/uni_ui/lib/calendar/calendar_item.dart b/packages/uni_ui/lib/calendar/calendar_item.dart index 3bafcc5e1..837272a5b 100644 --- a/packages/uni_ui/lib/calendar/calendar_item.dart +++ b/packages/uni_ui/lib/calendar/calendar_item.dart @@ -31,20 +31,37 @@ class CalendarItem extends StatelessWidget { fontSize: 11, ), ), - Container( - margin: EdgeInsets.only(top: 5), - width: 20, - height: 20, - decoration: BoxDecoration( - shape: BoxShape.circle, - border: Border.all( - color: Theme.of(context).colorScheme.primary, - width: 4.0, + Stack( + alignment: Alignment.bottomCenter, + children: [ + Container( + margin: EdgeInsets.only(top: 5, bottom: 12), + width: 20, + height: 20, + decoration: BoxDecoration( + shape: BoxShape.circle, + border: Border.all( + color: Theme.of(context).colorScheme.primary, + width: 4.0, + ) + ), + ), + Container( + width: 6, + height: 14, + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(3), + bottomRight: Radius.circular(3) + ), + shape: BoxShape.rectangle, + color: Theme.of(context).primaryColor, + ), ) - ), + ], ), Container( - margin: const EdgeInsets.all(10), + margin: const EdgeInsets.only(left: 5, right: 5, bottom: 10), padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 15), width: 140, decoration: ShapeDecoration( @@ -90,7 +107,7 @@ class CalendarItem extends StatelessWidget { ? "${start.day} ${monthToString(start.month)}." : "${start.day}-${end.day} ${monthToString(start.month)}."; } else { - return "${start.day} ${monthToString(start.month)}. - ${end.day} ${monthToString(end.month)}."; + return "${start.day} ${monthToString(start.month)} - ${end.day} ${monthToString(end.month)}"; } } } \ No newline at end of file From 88ce5765c342eb258ef78aa5e1ff6a4e4badf5de Mon Sep 17 00:00:00 2001 From: Process-ing Date: Sat, 26 Oct 2024 19:01:39 +0100 Subject: [PATCH 08/13] Add calendar line --- packages/uni_ui/lib/calendar/calendar.dart | 5 +- .../uni_ui/lib/calendar/calendar_item.dart | 67 +++++++++++++++---- 2 files changed, 57 insertions(+), 15 deletions(-) diff --git a/packages/uni_ui/lib/calendar/calendar.dart b/packages/uni_ui/lib/calendar/calendar.dart index 255beb06b..8d0a948f6 100644 --- a/packages/uni_ui/lib/calendar/calendar.dart +++ b/packages/uni_ui/lib/calendar/calendar.dart @@ -13,9 +13,10 @@ class Calendar extends StatelessWidget { Widget build(BuildContext context) { return SingleChildScrollView( scrollDirection: Axis.horizontal, - child: Row( // To avoid the widget from expanding vertically + child: Row( + // To avoid the widget from expanding vertically children: items, ), ); } -} \ No newline at end of file +} diff --git a/packages/uni_ui/lib/calendar/calendar_item.dart b/packages/uni_ui/lib/calendar/calendar_item.dart index 837272a5b..89c577427 100644 --- a/packages/uni_ui/lib/calendar/calendar_item.dart +++ b/packages/uni_ui/lib/calendar/calendar_item.dart @@ -35,7 +35,7 @@ class CalendarItem extends StatelessWidget { alignment: Alignment.bottomCenter, children: [ Container( - margin: EdgeInsets.only(top: 5, bottom: 12), + margin: EdgeInsets.only(top: 5, bottom: 10), width: 20, height: 20, decoration: BoxDecoration( @@ -43,21 +43,49 @@ class CalendarItem extends StatelessWidget { border: Border.all( color: Theme.of(context).colorScheme.primary, width: 4.0, - ) + ), ), ), Container( - width: 6, - height: 14, + width: 4, + height: 12, decoration: BoxDecoration( borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(3), - bottomRight: Radius.circular(3) - ), + bottomLeft: Radius.circular(3), + bottomRight: Radius.circular(3)), shape: BoxShape.rectangle, color: Theme.of(context).primaryColor, ), - ) + ), + Container( + margin: EdgeInsets.only(bottom: 18), + child: Row( + children: [ + Container( + width: 60, + height: 4, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.primary, + borderRadius: BorderRadius.only( + topRight: Radius.circular(3), + bottomRight: Radius.circular(3), + )), + ), + SizedBox(width: 30), + Container( + width: 60, + height: 4, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.primary, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(3), + bottomLeft: Radius.circular(3), + ), + ), + ), + ], + ), + ), ], ), Container( @@ -77,7 +105,7 @@ class CalendarItem extends StatelessWidget { color: Theme.of(context).colorScheme.shadow.withAlpha(0x3f), blurRadius: 6, ) - ] + ], ), child: Text( this.eventName, @@ -95,7 +123,20 @@ class CalendarItem extends StatelessWidget { static String monthToString(int month) { // TODO: Support English - const strMonths = ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dec"]; + const strMonths = [ + "Jan", + "Fev", + "Mar", + "Abr", + "Mai", + "Jun", + "Jul", + "Ago", + "Set", + "Out", + "Nov", + "Dec" + ]; return strMonths[month - 1]; } @@ -104,10 +145,10 @@ class CalendarItem extends StatelessWidget { if (start.month == end.month) { return start.day == end.day - ? "${start.day} ${monthToString(start.month)}." - : "${start.day}-${end.day} ${monthToString(start.month)}."; + ? "${start.day} ${monthToString(start.month)}." + : "${start.day} - ${end.day} ${monthToString(start.month)}."; } else { return "${start.day} ${monthToString(start.month)} - ${end.day} ${monthToString(end.month)}"; } } -} \ No newline at end of file +} From 0c1f43cadcfeb6033e13f64a693cdaed2032ae34 Mon Sep 17 00:00:00 2001 From: Process-ing Date: Sun, 27 Oct 2024 10:11:55 +0000 Subject: [PATCH 09/13] Add onTap to calendar items --- packages/uni_ui/lib/calendar/calendar.dart | 3 +- .../uni_ui/lib/calendar/calendar_item.dart | 61 ++++++++++--------- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/packages/uni_ui/lib/calendar/calendar.dart b/packages/uni_ui/lib/calendar/calendar.dart index 8d0a948f6..28a145cd6 100644 --- a/packages/uni_ui/lib/calendar/calendar.dart +++ b/packages/uni_ui/lib/calendar/calendar.dart @@ -11,10 +11,11 @@ class Calendar extends StatelessWidget { @override Widget build(BuildContext context) { + // Row + SingleChildScrollView is used, instead of ListView, to avoid + // the widget from expanding vertically return SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( - // To avoid the widget from expanding vertically children: items, ), ); diff --git a/packages/uni_ui/lib/calendar/calendar_item.dart b/packages/uni_ui/lib/calendar/calendar_item.dart index 89c577427..63880726b 100644 --- a/packages/uni_ui/lib/calendar/calendar_item.dart +++ b/packages/uni_ui/lib/calendar/calendar_item.dart @@ -6,10 +6,12 @@ class CalendarItem extends StatelessWidget { super.key, required this.eventName, required this.eventPeriod, + this.onTap, }); final String eventName; final DateTimeRange eventPeriod; + final void Function()? onTap; @override Widget build(BuildContext context) { @@ -17,7 +19,7 @@ class CalendarItem extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Text( - parsePeriod(this.eventPeriod), + parsePeriod(eventPeriod), style: TextStyle( fontSize: 15, height: 1, @@ -25,7 +27,7 @@ class CalendarItem extends StatelessWidget { ), ), Text( - this.eventPeriod.end.year.toString(), + eventPeriod.end.year.toString(), style: TextStyle( color: Theme.of(context).colorScheme.outline, fontSize: 11, @@ -88,32 +90,35 @@ class CalendarItem extends StatelessWidget { ), ], ), - Container( - margin: const EdgeInsets.only(left: 5, right: 5, bottom: 10), - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 15), - width: 140, - decoration: ShapeDecoration( - color: Theme.of(context).colorScheme.secondary, - shape: SmoothRectangleBorder( - borderRadius: SmoothBorderRadius( - cornerRadius: 12, - cornerSmoothing: 1, + GestureDetector( + onTap: onTap, + child: Container( + margin: const EdgeInsets.only(left: 5, right: 5, bottom: 10), + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 15), + width: 140, + decoration: ShapeDecoration( + color: Theme.of(context).colorScheme.secondary, + shape: SmoothRectangleBorder( + borderRadius: SmoothBorderRadius( + cornerRadius: 12, + cornerSmoothing: 1, + ), ), + shadows: [ + BoxShadow( + color: Theme.of(context).colorScheme.shadow.withAlpha(0x3f), + blurRadius: 6, + ) + ], ), - shadows: [ - BoxShadow( - color: Theme.of(context).colorScheme.shadow.withAlpha(0x3f), - blurRadius: 6, - ) - ], - ), - child: Text( - this.eventName, - style: TextStyle( - color: Theme.of(context).colorScheme.primary, - fontSize: 16, - fontWeight: FontWeight.w500, - height: 1, + child: Text( + eventName, + style: TextStyle( + color: Theme.of(context).colorScheme.primary, + fontSize: 16, + fontWeight: FontWeight.w500, + height: 1, + ), ), ), ), @@ -145,8 +150,8 @@ class CalendarItem extends StatelessWidget { if (start.month == end.month) { return start.day == end.day - ? "${start.day} ${monthToString(start.month)}." - : "${start.day} - ${end.day} ${monthToString(start.month)}."; + ? "${start.day} ${monthToString(start.month)}" + : "${start.day} - ${end.day} ${monthToString(start.month)}"; } else { return "${start.day} ${monthToString(start.month)} - ${end.day} ${monthToString(end.month)}"; } From 982423c11b86e59a34a34636dc6aa18e6f181471 Mon Sep 17 00:00:00 2001 From: Process-ing Date: Sun, 27 Oct 2024 10:43:07 +0000 Subject: [PATCH 10/13] Fix calendar items alignment and line connection --- packages/uni_ui/lib/calendar/calendar.dart | 78 +++++++++++++++++-- .../uni_ui/lib/calendar/calendar_item.dart | 35 +-------- 2 files changed, 74 insertions(+), 39 deletions(-) diff --git a/packages/uni_ui/lib/calendar/calendar.dart b/packages/uni_ui/lib/calendar/calendar.dart index 28a145cd6..3f77770e0 100644 --- a/packages/uni_ui/lib/calendar/calendar.dart +++ b/packages/uni_ui/lib/calendar/calendar.dart @@ -1,11 +1,68 @@ import 'package:flutter/material.dart'; import 'package:uni_ui/calendar/calendar_item.dart'; +class CalendarLine extends StatelessWidget { + const CalendarLine({ + super.key, + required this.calendarItemsCount, + }); + + final int calendarItemsCount; + + @override + Widget build(BuildContext context) { + if (calendarItemsCount == 0) return Container(); + + return Container( + margin: EdgeInsets.only(top: 44), + child: Row( + children: [ + Container( + width: 60, + height: 4, + margin: EdgeInsets.only(right: 15), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.primary, + borderRadius: BorderRadius.only( + topRight: Radius.circular(2), + bottomRight: Radius.circular(2), + ), + ), + ), + ...List.filled( + calendarItemsCount - 1, + Container( + width: 120, + height: 4, + margin: EdgeInsets.symmetric(horizontal: 15), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.primary, + borderRadius: BorderRadius.circular(2)), + ), + ), + Container( + width: 60, + height: 4, + margin: EdgeInsets.only(left: 15), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.primary, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(2), + bottomLeft: Radius.circular(2), + ), + ), + ), + ], + ), + ); + } +} + class Calendar extends StatelessWidget { const Calendar({ - Key? key, + super.key, required this.items, - }) : super(key: key); + }); final List items; @@ -14,10 +71,17 @@ class Calendar extends StatelessWidget { // Row + SingleChildScrollView is used, instead of ListView, to avoid // the widget from expanding vertically return SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - children: items, - ), - ); + scrollDirection: Axis.horizontal, + child: Stack( + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: items, + ), + CalendarLine( + calendarItemsCount: items.length, + ), + ], + )); } } diff --git a/packages/uni_ui/lib/calendar/calendar_item.dart b/packages/uni_ui/lib/calendar/calendar_item.dart index 63880726b..3a9e9fe26 100644 --- a/packages/uni_ui/lib/calendar/calendar_item.dart +++ b/packages/uni_ui/lib/calendar/calendar_item.dart @@ -53,47 +53,18 @@ class CalendarItem extends StatelessWidget { height: 12, decoration: BoxDecoration( borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(3), - bottomRight: Radius.circular(3)), + bottomLeft: Radius.circular(2), + bottomRight: Radius.circular(2)), shape: BoxShape.rectangle, color: Theme.of(context).primaryColor, ), ), - Container( - margin: EdgeInsets.only(bottom: 18), - child: Row( - children: [ - Container( - width: 60, - height: 4, - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.primary, - borderRadius: BorderRadius.only( - topRight: Radius.circular(3), - bottomRight: Radius.circular(3), - )), - ), - SizedBox(width: 30), - Container( - width: 60, - height: 4, - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.primary, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(3), - bottomLeft: Radius.circular(3), - ), - ), - ), - ], - ), - ), ], ), GestureDetector( onTap: onTap, child: Container( - margin: const EdgeInsets.only(left: 5, right: 5, bottom: 10), + margin: const EdgeInsets.only(left: 5, right: 5, bottom: 5), padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 15), width: 140, decoration: ShapeDecoration( From b892d0eef5b2642499f0cf08329f81d7e676acfe Mon Sep 17 00:00:00 2001 From: Process-ing Date: Sun, 27 Oct 2024 10:59:12 +0000 Subject: [PATCH 11/13] Add support for null dates --- .../uni_ui/lib/calendar/calendar_item.dart | 127 +++++++++++------- 1 file changed, 79 insertions(+), 48 deletions(-) diff --git a/packages/uni_ui/lib/calendar/calendar_item.dart b/packages/uni_ui/lib/calendar/calendar_item.dart index 3a9e9fe26..52b02cab3 100644 --- a/packages/uni_ui/lib/calendar/calendar_item.dart +++ b/packages/uni_ui/lib/calendar/calendar_item.dart @@ -1,16 +1,92 @@ import 'package:figma_squircle/figma_squircle.dart'; import 'package:flutter/material.dart'; +class _CalendarItemDate extends StatelessWidget { + const _CalendarItemDate({ + required this.eventPeriod, + }); + + final DateTimeRange? eventPeriod; + + @override + Widget build(BuildContext context) { + if (eventPeriod != null) { + return Column( + children: [ + Text( + parsePeriod(eventPeriod!), + style: TextStyle( + fontSize: 15, + height: 1, + fontWeight: FontWeight.w500, + ), + ), + Text( + eventPeriod!.end.year.toString(), + style: TextStyle( + color: Theme.of(context).colorScheme.outline, + fontSize: 11, + ), + ), + ], + ); + + } else { + return Padding( + padding: EdgeInsets.only(top: 10), + child: Text( + "TBD", + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w500, + ), + ), + ); + } + } + + static String monthToString(int month) { + // TODO: Support Portuguese + const strMonths = [ + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec" + ]; + return strMonths[month - 1]; + } + + static String parsePeriod(DateTimeRange period) { + final start = period.start, end = period.end; + + if (start.month == end.month) { + return start.day == end.day + ? "${start.day} ${monthToString(start.month)}" + : "${start.day} - ${end.day} ${monthToString(start.month)}"; + } else { + return "${start.day} ${monthToString(start.month)} - ${end.day} ${monthToString(end.month)}"; + } + } +} + class CalendarItem extends StatelessWidget { const CalendarItem({ super.key, required this.eventName, - required this.eventPeriod, + this.eventPeriod, this.onTap, }); final String eventName; - final DateTimeRange eventPeriod; + final DateTimeRange? eventPeriod; final void Function()? onTap; @override @@ -18,21 +94,7 @@ class CalendarItem extends StatelessWidget { return Column( mainAxisSize: MainAxisSize.min, children: [ - Text( - parsePeriod(eventPeriod), - style: TextStyle( - fontSize: 15, - height: 1, - fontWeight: FontWeight.w500, - ), - ), - Text( - eventPeriod.end.year.toString(), - style: TextStyle( - color: Theme.of(context).colorScheme.outline, - fontSize: 11, - ), - ), + _CalendarItemDate(eventPeriod: eventPeriod), Stack( alignment: Alignment.bottomCenter, children: [ @@ -96,35 +158,4 @@ class CalendarItem extends StatelessWidget { ], ); } - - static String monthToString(int month) { - // TODO: Support English - const strMonths = [ - "Jan", - "Fev", - "Mar", - "Abr", - "Mai", - "Jun", - "Jul", - "Ago", - "Set", - "Out", - "Nov", - "Dec" - ]; - return strMonths[month - 1]; - } - - static String parsePeriod(DateTimeRange period) { - final start = period.start, end = period.end; - - if (start.month == end.month) { - return start.day == end.day - ? "${start.day} ${monthToString(start.month)}" - : "${start.day} - ${end.day} ${monthToString(start.month)}"; - } else { - return "${start.day} ${monthToString(start.month)} - ${end.day} ${monthToString(end.month)}"; - } - } } From d5b9f16e77ce01bfc66e268308008b685c90998b Mon Sep 17 00:00:00 2001 From: Process-ing Date: Sun, 27 Oct 2024 10:59:49 +0000 Subject: [PATCH 12/13] Fix formatting --- packages/uni_ui/lib/calendar/calendar_item.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/uni_ui/lib/calendar/calendar_item.dart b/packages/uni_ui/lib/calendar/calendar_item.dart index 52b02cab3..f2dfde878 100644 --- a/packages/uni_ui/lib/calendar/calendar_item.dart +++ b/packages/uni_ui/lib/calendar/calendar_item.dart @@ -30,7 +30,6 @@ class _CalendarItemDate extends StatelessWidget { ), ], ); - } else { return Padding( padding: EdgeInsets.only(top: 10), From a4048ba5186ab681bc465c3b69aa160d531c1b0b Mon Sep 17 00:00:00 2001 From: DGoiana Date: Thu, 2 Jan 2025 18:14:32 +0000 Subject: [PATCH 13/13] moved out string parser to app --- .../uni_ui/lib/calendar/calendar_item.dart | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/uni_ui/lib/calendar/calendar_item.dart b/packages/uni_ui/lib/calendar/calendar_item.dart index f2dfde878..0081e557c 100644 --- a/packages/uni_ui/lib/calendar/calendar_item.dart +++ b/packages/uni_ui/lib/calendar/calendar_item.dart @@ -2,11 +2,10 @@ import 'package:figma_squircle/figma_squircle.dart'; import 'package:flutter/material.dart'; class _CalendarItemDate extends StatelessWidget { - const _CalendarItemDate({ - required this.eventPeriod, - }); + const _CalendarItemDate({this.eventPeriod, this.endYear}); - final DateTimeRange? eventPeriod; + final String? eventPeriod; + final String? endYear; @override Widget build(BuildContext context) { @@ -14,7 +13,7 @@ class _CalendarItemDate extends StatelessWidget { return Column( children: [ Text( - parsePeriod(eventPeriod!), + eventPeriod!, style: TextStyle( fontSize: 15, height: 1, @@ -22,7 +21,7 @@ class _CalendarItemDate extends StatelessWidget { ), ), Text( - eventPeriod!.end.year.toString(), + endYear ?? '', style: TextStyle( color: Theme.of(context).colorScheme.outline, fontSize: 11, @@ -44,6 +43,7 @@ class _CalendarItemDate extends StatelessWidget { } } +/* TODO: move this to uni_app later static String monthToString(int month) { // TODO: Support Portuguese const strMonths = [ @@ -74,6 +74,8 @@ class _CalendarItemDate extends StatelessWidget { return "${start.day} ${monthToString(start.month)} - ${end.day} ${monthToString(end.month)}"; } } + + */ } class CalendarItem extends StatelessWidget { @@ -81,11 +83,13 @@ class CalendarItem extends StatelessWidget { super.key, required this.eventName, this.eventPeriod, + this.endYear, this.onTap, }); final String eventName; - final DateTimeRange? eventPeriod; + final String? eventPeriod; + final String? endYear; final void Function()? onTap; @override @@ -93,7 +97,10 @@ class CalendarItem extends StatelessWidget { return Column( mainAxisSize: MainAxisSize.min, children: [ - _CalendarItemDate(eventPeriod: eventPeriod), + _CalendarItemDate( + eventPeriod: eventPeriod, + endYear: endYear, + ), Stack( alignment: Alignment.bottomCenter, children: [