diff --git a/Sources/justMUSIC/lib/components/historic_component.dart b/Sources/justMUSIC/lib/components/historic_component.dart new file mode 100644 index 0000000..7d0e758 --- /dev/null +++ b/Sources/justMUSIC/lib/components/historic_component.dart @@ -0,0 +1,43 @@ +import 'package:flutter/Material.dart'; + +class HistoricComponent extends StatefulWidget { + final int month; + const HistoricComponent({super.key, required this.month}); + + @override + State createState() => _HistoricComponentState(); +} + +class _HistoricComponentState extends State { + int getNumberOfDaysInMonth(int year, int month) { + if (month < 1 || month > 12) { + throw ArgumentError("Le numéro de mois doit être compris entre 1 et 12."); + } + + return DateTime(year, month + 1, 0).day; + } + + @override + Widget build(BuildContext context) { + return Wrap( + spacing: 14, + runSpacing: 14, + children: List.generate(getNumberOfDaysInMonth(DateTime.now().year, widget.month), (index) { + // Generate widgets + return LimitedBox( + maxWidth: MediaQuery.of(context).size.width - 40 / 5, + child: Container( + decoration: BoxDecoration( + gradient: LinearGradient(colors: [ + Color(0xFF1E1E1E).withOpacity(0.7), + Color(0xFF1E1E1E).withOpacity(0), + ], begin: Alignment.topCenter, end: Alignment.bottomCenter), + borderRadius: BorderRadius.circular(3)), + height: 60, + width: 60, + ), + ); + }), + ); + } +} diff --git a/Sources/justMUSIC/lib/config/routes.dart b/Sources/justMUSIC/lib/config/routes.dart index a9f0df0..4b36efa 100644 --- a/Sources/justMUSIC/lib/config/routes.dart +++ b/Sources/justMUSIC/lib/config/routes.dart @@ -1,5 +1,6 @@ import 'package:flutter/Material.dart'; import 'package:justmusic/screens/add_friend_screen.dart'; +import 'package:justmusic/screens/capsule_historic_screen.dart'; import 'package:justmusic/screens/change_password_screen.dart'; import 'package:justmusic/screens/feed_screen.dart'; import 'package:justmusic/screens/profile_screen.dart'; @@ -90,3 +91,21 @@ Route routePassword() { }, ); } + +Route routeHistoric() { + return PageRouteBuilder( + pageBuilder: (context, animation, secondaryAnimation) => const CapsuleHistoricScreen(), + transitionsBuilder: (context, animation, secondaryAnimation, child) { + const begin = Offset(1.0, 0.0); + const end = Offset.zero; + const curve = Curves.ease; + + var tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve)); + + return SlideTransition( + position: animation.drive(tween), + child: child, + ); + }, + ); +} diff --git a/Sources/justMUSIC/lib/screens/capsule_historic_screen.dart b/Sources/justMUSIC/lib/screens/capsule_historic_screen.dart new file mode 100644 index 0000000..d6fe2c7 --- /dev/null +++ b/Sources/justMUSIC/lib/screens/capsule_historic_screen.dart @@ -0,0 +1,94 @@ +import 'package:flutter/Material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +import '../components/historic_component.dart'; +import '../values/constants.dart'; + +class CapsuleHistoricScreen extends StatefulWidget { + const CapsuleHistoricScreen({super.key}); + + @override + State createState() => _CapsuleHistoricScreenState(); +} + +class _CapsuleHistoricScreenState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: PreferredSize( + preferredSize: Size(double.infinity, 58), + child: Container( + height: double.infinity, + color: bgAppBar, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: defaultPadding), + child: Stack( + alignment: Alignment.centerLeft, + children: [ + GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: () { + Navigator.pop(context, true); + }, + child: Container( + padding: EdgeInsets.symmetric(horizontal: 10), + height: 30, + width: 30, + child: Image( + image: AssetImage("assets/images/return_icon.png"), + height: 8, + ), + )), + Align( + child: Text( + "Historique des capsules", + style: GoogleFonts.plusJakartaSans(color: Colors.white, fontSize: 14, fontWeight: FontWeight.bold), + ), + ) + ], + ), + ), + ), + ), + body: Container( + width: double.infinity, + height: double.infinity, + color: bgColor, + child: SingleChildScrollView( + physics: const BouncingScrollPhysics(decelerationRate: ScrollDecelerationRate.fast), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: settingPadding), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(top: 30, bottom: 40), + child: SizedBox( + width: double.infinity, + child: Stack( + alignment: Alignment.center, + children: [ + Container( + padding: EdgeInsets.symmetric(horizontal: 15), + constraints: BoxConstraints(maxWidth: 600), + child: Column( + children: [ + HistoricComponent( + month: DateTime.now().month, + ), + ], + ), + ) + ], + ), + ), + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/Sources/justMUSIC/lib/screens/profile_screen.dart b/Sources/justMUSIC/lib/screens/profile_screen.dart index ab9835d..54cf845 100644 --- a/Sources/justMUSIC/lib/screens/profile_screen.dart +++ b/Sources/justMUSIC/lib/screens/profile_screen.dart @@ -26,6 +26,10 @@ class _ProfileScreenState extends State { Navigator.pushNamed(context, '/welcome'); } + void _openHistoric() { + Navigator.of(context).push(routeHistoric()); + } + void _openDetail() { Navigator.of(context).push(routeUser(MyApp.userViewModel.userCurrent)); } @@ -107,10 +111,10 @@ class _ProfileScreenState extends State { label: 'Compte', action: _openDetail, ), - const SettingPartComponent( + SettingPartComponent( icon: JustMusicIcon.history, label: 'Historiques des capsules', - action: null, + action: _openHistoric, ), const SettingPartComponent( icon: JustMusicIcon.spotify,