1+ import 'dart:developer' ;
2+
13import 'package:collection/collection.dart' ;
24import 'package:flutter/material.dart' ;
35import 'package:threeactions_area/resources/Resources.dart' ;
6+ import 'package:threeactions_area/widgets/base/TextContent.dart' ;
47import 'package:threeactions_area/widgets/base/TextTitle.dart' ;
58import 'package:threeactions_area/widgets/base/TextTitleBig.dart' ;
69
710class ImageModel {
811 String resourcePath;
912 String title;
1013 String description;
14+ String ? goToUrl = null ;
1115
12- ImageModel ({required this .resourcePath, required this .title, required this .description});
16+ ImageModel (
17+ {required this .resourcePath,
18+ required this .title,
19+ required this .description,
20+ this .goToUrl = null });
1321}
1422
1523class ImageGallery extends StatefulWidget {
1624 final List <ImageModel > imagesResList;
25+ final Function (String ? ) onClickedAction;
1726 Color accentFilterColor = AppColors .ContentWhite ;
1827
19- ImageGallery ({super .key, required this .imagesResList, this .accentFilterColor = AppColors .ContentWhite });
28+ ImageGallery ({
29+ super .key,
30+ required this .imagesResList,
31+ required this .onClickedAction,
32+ this .accentFilterColor = AppColors .ContentWhite ,
33+ });
2034
2135 @override
2236 State <StatefulWidget > createState () {
23- return SimpleGalleryState (imagesResList: imagesResList, accentFilterColor: accentFilterColor);
37+ return SimpleGalleryState (
38+ imagesResList: imagesResList,
39+ accentFilterColor: accentFilterColor,
40+ onClickedAction: onClickedAction);
2441 }
2542}
2643
2744class SimpleGalleryState extends State with TickerProviderStateMixin {
2845 final List <ImageModel > imagesResList;
46+ final Function (String ? ) onClickedAction;
2947 final accentFilterColor;
3048
3149 var widthsList = [];
@@ -36,15 +54,21 @@ class SimpleGalleryState extends State with TickerProviderStateMixin {
3654 List <AnimationController > controllers = [];
3755 List <Animation > opacityAcnimations = [];
3856
39- SimpleGalleryState ({required this .imagesResList, this .accentFilterColor});
57+ SimpleGalleryState (
58+ {required this .imagesResList,
59+ this .accentFilterColor,
60+ required this .onClickedAction});
4061
4162 @override
4263 void initState () {
4364 super .initState ();
4465
4566 for (final (index, item) in imagesResList.indexed) {
4667 controllers.add (
47- AnimationController (vsync: this , duration: Duration (milliseconds: 300 ), animationBehavior: AnimationBehavior .normal)
68+ AnimationController (
69+ vsync: this ,
70+ duration: Duration (milliseconds: 300 ),
71+ animationBehavior: AnimationBehavior .normal)
4872 ..addListener (() {
4973 setState (() {});
5074 }),
@@ -57,8 +81,7 @@ class SimpleGalleryState extends State with TickerProviderStateMixin {
5781 List <Widget > _buildImageWidgets (BoxConstraints constraints) {
5882 List <Widget > widgets = [];
5983 imagesResList.forEachIndexed ((index, element) {
60- widgets.add (
61- InkWell (
84+ widgets.add (InkWell (
6285 onTap: () {},
6386 onHover: (isHovered) {
6487 _updateWidthsAndOpacity (isHovered, index);
@@ -70,42 +93,66 @@ class SimpleGalleryState extends State with TickerProviderStateMixin {
7093 width: widthsList[index],
7194 curve: Curves .fastOutSlowIn,
7295 duration: Durations .long1,
73- child: Stack (
74- fit: StackFit .expand,
75- children: [
76- Image .asset (
77- imagesResList[index].resourcePath,
78- fit: BoxFit .cover,
79- height: constraints.maxHeight, //48 - external padding
80- ),
81- Opacity (
82- opacity: opacityAcnimations[index].value,
83- child: Align (
84- alignment: Alignment .bottomCenter,
85- child: Column (
86- mainAxisAlignment: MainAxisAlignment .center,
87- crossAxisAlignment: CrossAxisAlignment .center,
88- children: [
89- Spacer (),
90- TextTitleBig (text: imagesResList[index].title, textColor: accentFilterColor,),
91- TextTitle (text: imagesResList[index].description, textColor: accentFilterColor,),
92- SizedBox (
93- height: 32.0 ,
94- )
95- ],
96- ),
96+ child: InkWell (
97+ onTap: () {
98+ log ("CLICK - url = ${imagesResList [index ].goToUrl }" );
99+ onClickedAction (imagesResList[index].goToUrl);
100+ },
101+ child: Stack (
102+ fit: StackFit .expand,
103+ children: [
104+ Image .asset (
105+ imagesResList[index].resourcePath,
106+ fit: BoxFit .cover,
107+ height: constraints.maxHeight, //48 - external padding
97108 ),
98- )
99- ],
109+ Opacity (
110+ opacity: opacityAcnimations[index].value,
111+ child: Align (
112+ alignment: Alignment .bottomCenter,
113+ child: Column (
114+ mainAxisAlignment: MainAxisAlignment .center,
115+ crossAxisAlignment: CrossAxisAlignment .center,
116+ children: [
117+ Spacer (),
118+ Container (
119+ color: AppColors .BgBlack45 ,
120+ child: Column (
121+ mainAxisAlignment: MainAxisAlignment .center,
122+ crossAxisAlignment: CrossAxisAlignment .stretch,
123+ children: [
124+ SizedBox (
125+ height: 16.0 ,
126+ ),
127+ TextTitle (
128+ text: imagesResList[index].title,
129+ textColor: accentFilterColor,
130+ textAlign: TextAlign .center,
131+ ),
132+ TextContent (
133+ text: imagesResList[index].description,
134+ textColor: accentFilterColor,
135+ textAlign: TextAlign .center,
136+ ),
137+ SizedBox (
138+ height: 32.0 ,
139+ )
140+ ],
141+ ),
142+ )
143+ ],
144+ ),
145+ ),
146+ )
147+ ],
148+ ),
100149 ),
101150 ),
102151 ],
103152 ),
104- )
105- );
153+ ));
106154 });
107155
108-
109156 return widgets;
110157 }
111158
@@ -151,8 +198,6 @@ class SimpleGalleryState extends State with TickerProviderStateMixin {
151198 hoveredIndex = - 1 ;
152199 widthsList = imagesResList.map ((e) => baseWidth).toList ();
153200 }
154- // print("HOVER $hoveredIndex");
155- // print("WIDTHS $widthsList");
156201 });
157202 }
158203}
0 commit comments