Skip to content

Commit e6ebcca

Browse files
authored
7.3.5 ThemedNavigatorWidget (#97)
2 parents b61c7ba + 638741b commit e6ebcca

8 files changed

Lines changed: 182 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 7.3.5
4+
5+
- Added `ThemedNavigatorWidget` to the `ThemedNavigatorItem` class elements to allow full custom widgets to be added.
6+
7+
## 7.3.4
8+
9+
- Updated
10+
311
## 7.3.3
412
- add `isDense` in `ThemedTimePicker`
513

lib/src/layout/src/appbar/mobile.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,37 @@ class _ThemedMobileAppBarState extends State<ThemedMobileAppBar> with TickerProv
377377
);
378378
}
379379

380+
if (item is ThemedNavigatorWidget) {
381+
return ThemedTooltip(
382+
position: ThemedTooltipPosition.right,
383+
message: item.labelText ?? item.label?.toString() ?? '',
384+
child: Container(
385+
margin: const EdgeInsets.all(5),
386+
width: actionSize - 10,
387+
height: actionSize - 10,
388+
decoration: BoxDecoration(
389+
borderRadius: BorderRadius.circular(actionSize),
390+
),
391+
child: Material(
392+
color: Colors.transparent,
393+
child: InkWell(
394+
borderRadius: BorderRadius.circular(actionSize),
395+
hoverColor: validateColor(color: backgroundColor).withValues(alpha: 0.1),
396+
onTap: item.onTap,
397+
child: Container(
398+
alignment: Alignment.center,
399+
constraints: const BoxConstraints(
400+
minWidth: 30,
401+
minHeight: 30,
402+
),
403+
child: item.widget,
404+
),
405+
),
406+
),
407+
),
408+
);
409+
}
410+
380411
return const SizedBox();
381412
}
382413
}

lib/src/layout/src/bars/bottom.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,37 @@ class _ThemedBottomBarState extends State<ThemedBottomBar> with TickerProviderSt
341341
);
342342
}
343343

344+
if (item is ThemedNavigatorWidget) {
345+
return ThemedTooltip(
346+
position: ThemedTooltipPosition.right,
347+
message: item.labelText ?? item.label?.toString() ?? '',
348+
child: Container(
349+
margin: const EdgeInsets.all(5),
350+
width: actionSize - 10,
351+
height: actionSize - 10,
352+
decoration: BoxDecoration(
353+
borderRadius: BorderRadius.circular(actionSize),
354+
),
355+
child: Material(
356+
color: Colors.transparent,
357+
child: InkWell(
358+
borderRadius: BorderRadius.circular(actionSize),
359+
hoverColor: validateColor(color: backgroundColor).withValues(alpha: 0.1),
360+
onTap: item.onTap,
361+
child: Container(
362+
alignment: Alignment.center,
363+
constraints: const BoxConstraints(
364+
minWidth: 30,
365+
minHeight: 30,
366+
),
367+
child: item.widget,
368+
),
369+
),
370+
),
371+
),
372+
);
373+
}
374+
344375
return const SizedBox();
345376
}
346377
}

lib/src/layout/src/bars/dual.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class _ThemedDualBarState extends State<ThemedDualBar> {
4545
widget.onNavigatorPush ?? (path) => Navigator.of(context).pushNamed(path);
4646

4747
List<ThemedNavigatorItem> _children = [];
48+
double get actionSize => 50;
4849

4950
@override
5051
void initState() {
@@ -236,6 +237,36 @@ class _ThemedDualBarState extends State<ThemedDualBar> {
236237
),
237238
);
238239
}
240+
if (item is ThemedNavigatorWidget) {
241+
return ThemedTooltip(
242+
position: ThemedTooltipPosition.right,
243+
message: item.labelText ?? item.label?.toString() ?? '',
244+
child: Container(
245+
margin: const EdgeInsets.all(5),
246+
width: actionSize - 10,
247+
height: actionSize - 10,
248+
decoration: BoxDecoration(
249+
borderRadius: BorderRadius.circular(actionSize),
250+
),
251+
child: Material(
252+
color: Colors.transparent,
253+
child: InkWell(
254+
borderRadius: BorderRadius.circular(actionSize),
255+
hoverColor: validateColor(color: backgroundColor).withValues(alpha: 0.1),
256+
onTap: item.onTap,
257+
child: Container(
258+
alignment: Alignment.center,
259+
constraints: const BoxConstraints(
260+
minWidth: 30,
261+
minHeight: 30,
262+
),
263+
child: item.widget,
264+
),
265+
),
266+
),
267+
),
268+
);
269+
}
239270

240271
return const SizedBox();
241272
}

lib/src/layout/src/bars/mini.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,37 @@ class _ThemedMiniBarState extends State<ThemedMiniBar> with TickerProviderStateM
422422
);
423423
}
424424

425+
if (item is ThemedNavigatorWidget) {
426+
return ThemedTooltip(
427+
position: ThemedTooltipPosition.right,
428+
message: item.labelText ?? item.label?.toString() ?? '',
429+
child: Container(
430+
margin: const EdgeInsets.all(5),
431+
width: actionSize - 10,
432+
height: actionSize - 10,
433+
decoration: BoxDecoration(
434+
borderRadius: BorderRadius.circular(actionSize),
435+
),
436+
child: Material(
437+
color: Colors.transparent,
438+
child: InkWell(
439+
borderRadius: BorderRadius.circular(actionSize),
440+
hoverColor: validateColor(color: backgroundColor).withValues(alpha: 0.1),
441+
onTap: item.onTap,
442+
child: Container(
443+
alignment: Alignment.center,
444+
constraints: const BoxConstraints(
445+
minWidth: 30,
446+
minHeight: 30,
447+
),
448+
child: item.widget,
449+
),
450+
),
451+
),
452+
),
453+
);
454+
}
455+
425456
return const SizedBox();
426457
}
427458
}

lib/src/layout/src/bars/side.dart

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ class _ThemedSidebarState extends State<ThemedSidebar> with TickerProviderStateM
167167

168168
String get currentPath => widget.currentPath ?? '';
169169

170+
double get actionSize => 50;
171+
170172
late AnimationController _actionsAnimation;
171173

172174
@override
@@ -607,6 +609,37 @@ class _ThemedSidebarState extends State<ThemedSidebar> with TickerProviderStateM
607609
);
608610
}
609611

612+
if (item is ThemedNavigatorWidget) {
613+
return ThemedTooltip(
614+
position: ThemedTooltipPosition.right,
615+
message: item.labelText ?? item.label?.toString() ?? '',
616+
child: Container(
617+
margin: const EdgeInsets.all(5),
618+
width: actionSize - 10,
619+
height: actionSize - 10,
620+
decoration: BoxDecoration(
621+
borderRadius: BorderRadius.circular(actionSize),
622+
),
623+
child: Material(
624+
color: Colors.transparent,
625+
child: InkWell(
626+
borderRadius: BorderRadius.circular(actionSize),
627+
hoverColor: validateColor(color: backgroundColor).withValues(alpha: 0.1),
628+
onTap: item.onTap,
629+
child: Container(
630+
alignment: Alignment.center,
631+
constraints: const BoxConstraints(
632+
minWidth: 30,
633+
minHeight: 30,
634+
),
635+
child: item.widget,
636+
),
637+
),
638+
),
639+
),
640+
);
641+
}
642+
610643
return const SizedBox();
611644
}
612645
}

lib/src/layout/src/models.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,22 @@ class ThemedNavigatorAction extends ThemedNavigatorItem {
101101
}) : assert(label != null || labelText != null);
102102
}
103103

104+
class ThemedNavigatorWidget extends ThemedNavigatorItem {
105+
/// [widget] is the widget to be displayed in the view.
106+
final Widget widget;
107+
108+
/// [onTap] is the action to be executed when the item is tapped.
109+
final VoidCallback? onTap;
110+
111+
/// [ThemedNavigatorWidget] is a helper class to handle the widgets of the view.
112+
ThemedNavigatorWidget({
113+
super.label,
114+
super.labelText,
115+
this.onTap,
116+
required this.widget,
117+
}) : assert(label != null || labelText != null);
118+
}
119+
104120
class ThemedNavigatorSeparator extends ThemedNavigatorItem {
105121
/// [type] is the type of the separator.
106122
final ThemedSeparatorType type;

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: layrz_theme
22
description: Layrz standard styling library for Flutter. Widget library following the Material Design 3 guidelines, with a focus on reliavility and functionality.
3-
version: "7.3.4"
3+
version: "7.3.5"
44
homepage: https://theme.layrz.com
55
repository: https://github.com/goldenm-software/layrz_theme
66

0 commit comments

Comments
 (0)