Skip to content

Commit d56569e

Browse files
committed
Updated ImageGallery, improved test widgets, fixed external url redirects
1 parent c72aded commit d56569e

15 files changed

+177
-92
lines changed

assets/img/img_gallery_1.jpg

999 KB
Loading

assets/img/img_gallery_2.jpg

270 KB
Loading

assets/img/img_gallery_3.jpg

379 KB
Loading

assets/img/img_gallery_4.jpg

634 KB
Loading

assets/img/img_gallery_5.jpg

292 KB
Loading

lib/pages/TestPage.dart

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:threeactions_area/resources/Resources.dart';
44
import 'package:threeactions_area/widgets/base/TextContent.dart';
55
import 'package:threeactions_area/widgets/base/TextSubtitle.dart';
66
import 'package:threeactions_area/widgets/base/TextTitle.dart';
7+
import 'package:url_launcher/url_launcher_string.dart';
78

89
import '../widgets/base/ImageGallery.dart';
910
import '../widgets/base/MainPageInfoButton.dart';
@@ -173,27 +174,33 @@ class TestPageState extends State {
173174
accentFilterColor: AppColors.ContentLightYellow,
174175
content: ImageGallery(
175176
accentFilterColor: AppColors.ContentLightYellow,
177+
onClickedAction: _handleRedirect,
176178
imagesResList: [
177179
ImageModel(
178-
resourcePath: "assets/img/button_bg_bio.png",
179-
title: "Cube 1",
180-
description: "Description 1"),
180+
resourcePath: "assets/img/img_gallery_1.jpg",
181+
title: "Do you really want it?",
182+
description: "Part of my favorite songs",
183+
goToUrl: "https://www.artstation.com/artwork/G8NeGQ"),
181184
ImageModel(
182-
resourcePath: "assets/img/button_bg_skills.png",
183-
title: "Cube 2",
184-
description: "Description 2"),
185+
resourcePath: "assets/img/img_gallery_2.jpg",
186+
title: "Feel nothing",
187+
description: "Bad thoughts and this is its representation",
188+
goToUrl: "https://www.artstation.com/artwork/NG60w5"),
185189
ImageModel(
186-
resourcePath: "assets/img/button_bg_contacts.png",
187-
title: "Cube 3",
188-
description: "Description 3"),
190+
resourcePath: "assets/img/img_gallery_3.jpg",
191+
title: "Cube in cave",
192+
description: "Experiment with volumetric lights",
193+
goToUrl: "https://www.artstation.com/artwork/KOWeoo"),
189194
ImageModel(
190-
resourcePath: "assets/img/button_bg_art.png",
191-
title: "Cube 4",
192-
description: "Description 4"),
195+
resourcePath: "assets/img/img_gallery_4.jpg",
196+
title: "Zero comfort zone",
197+
description: "My first try with photoreal materials and light",
198+
goToUrl: "https://www.artstation.com/artwork/yJVD5x"),
193199
ImageModel(
194-
resourcePath: "assets/img/button_bg_bio.png",
195-
title: "Cube 5",
196-
description: "Description 5"),
200+
resourcePath: "assets/img/img_gallery_5.jpg",
201+
title: "Art for my track",
202+
description: "Unusual environment with my music logo",
203+
goToUrl: "https://www.artstation.com/artwork/r9VJ1J"),
197204
]),
198205
);
199206
}
@@ -259,4 +266,12 @@ class TestPageState extends State {
259266
),
260267
);
261268
}
269+
270+
void _handleRedirect(String? redirectUrl) async {
271+
if (redirectUrl == null) return;
272+
273+
if (await canLaunchUrlString(redirectUrl)) {
274+
await launchUrlString(redirectUrl);
275+
}
276+
}
262277
}

lib/resources/Resources.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ class AppColors {
66
static const ContentLightYellow = Color(0xffFFFFB5);
77
static const ContentLightBlue = Color(0xff6BC5E3);
88
static const ContentLightRed = Color(0xffE6A8A1);
9+
10+
static const BgBlack45 = Color(0xA6000000);
911
}
1012
class TextStylesContent {
1113

lib/widgets/base/ImageGallery.dart

Lines changed: 83 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,49 @@
1+
import 'dart:developer';
2+
13
import 'package:collection/collection.dart';
24
import 'package:flutter/material.dart';
35
import 'package:threeactions_area/resources/Resources.dart';
6+
import 'package:threeactions_area/widgets/base/TextContent.dart';
47
import 'package:threeactions_area/widgets/base/TextTitle.dart';
58
import 'package:threeactions_area/widgets/base/TextTitleBig.dart';
69

710
class 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

1523
class 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

2744
class 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
}

lib/widgets/base/SocialButton.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class SocialButton extends StatelessWidget {
3434

3535
void _handleRedirect(String redirectUrl) async {
3636
if (await canLaunchUrlString(redirectUrl)) {
37-
await canLaunchUrlString(redirectUrl);
37+
await launchUrlString(redirectUrl);
3838
}
3939
}
4040
}

lib/widgets/base/TextContent.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ import '../../resources/Resources.dart';
66
class TextContent extends StatelessWidget {
77
final String text;
88
Color textColor = AppColors.ContentWhite;
9+
TextAlign textAlign = TextAlign.start;
910

10-
TextContent({this.text = "", this.textColor = AppColors.ContentWhite});
11+
TextContent(
12+
{this.text = "",
13+
this.textColor = AppColors.ContentWhite,
14+
this.textAlign = TextAlign.start});
1115

1216
@override
1317
Widget build(BuildContext context) {
14-
return (
15-
Text(text, style: TextStylesContent.Content.copyWith(
16-
color: textColor
17-
))
18-
);
18+
return (Text(
19+
text,
20+
style: TextStylesContent.Content.copyWith(color: textColor),
21+
textAlign: textAlign,
22+
));
1923
}
20-
21-
}
24+
}

0 commit comments

Comments
 (0)