Skip to content

Commit cfc3595

Browse files
authored
Merge pull request #55 from nadavfima/toolbar-gradient-parameter
feat: add enableToolbarGradient option to AdaptiveScaffold and iOS26 components for enhanced UI customization
2 parents caf261a + 81bc04c commit cfc3595

File tree

4 files changed

+35
-20
lines changed

4 files changed

+35
-20
lines changed

lib/src/widgets/adaptive_scaffold.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class AdaptiveScaffold extends StatefulWidget {
6969
this.floatingActionButton,
7070
this.minimizeBehavior = TabBarMinimizeBehavior.automatic,
7171
this.enableBlur = true,
72+
this.enableToolbarGradient = true,
7273
this.extendBodyBehindAppBar = false,
7374
});
7475

@@ -94,6 +95,9 @@ class AdaptiveScaffold extends StatefulWidget {
9495
/// When enabled, content behind the tab bar will be blurred
9596
final bool enableBlur;
9697

98+
/// Enable gradient at the top of the toolbar (iOS 26+ only)
99+
/// When enabled, a gradient fade effect is applied to the top toolbar
100+
final bool enableToolbarGradient;
97101
/// Whether to extend the body behind the app bar (iOS only)
98102
/// When true, the body will extend behind the app bar, allowing for
99103
/// immersive content. When false, the body will start below the app bar.
@@ -169,6 +173,7 @@ class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
169173
leading: widget.appBar?.leading,
170174
minimizeBehavior: widget.minimizeBehavior,
171175
enableBlur: widget.enableBlur,
176+
enableToolbarGradient: widget.enableToolbarGradient,
172177
children: childrenList,
173178
);
174179
}

lib/src/widgets/ios26/ios26_native_toolbar.dart

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class IOS26NativeToolbar extends StatefulWidget {
1818
this.onLeadingTap,
1919
this.onActionTap,
2020
this.height = 44.0,
21+
this.enableGradient = true,
2122
});
2223

2324
final String? title;
@@ -27,6 +28,7 @@ class IOS26NativeToolbar extends StatefulWidget {
2728
final VoidCallback? onLeadingTap;
2829
final ValueChanged<int>? onActionTap;
2930
final double height;
31+
final bool enableGradient;
3032

3133
@override
3234
State<IOS26NativeToolbar> createState() => _IOS26NativeToolbarState();
@@ -58,26 +60,28 @@ class _IOS26NativeToolbarState extends State<IOS26NativeToolbar> {
5860

5961
final toolbar = Container(
6062
height: widget.height + safePadding,
61-
decoration: BoxDecoration(
62-
gradient: Theme.brightnessOf(context) == Brightness.light
63-
? const LinearGradient(
64-
colors: [
65-
Color.fromARGB(229, 255, 255, 255),
66-
Color.fromARGB(0, 255, 255, 255),
67-
],
68-
begin: Alignment.topCenter,
69-
end: Alignment.bottomCenter,
70-
)
71-
: const LinearGradient(
72-
colors: [
73-
Color.fromARGB(234, 0, 0, 0),
74-
Color.fromARGB(137, 0, 0, 0),
75-
Color.fromARGB(0, 0, 0, 0),
76-
],
77-
begin: Alignment.topCenter,
78-
end: Alignment.bottomCenter,
79-
),
80-
),
63+
decoration: widget.enableGradient
64+
? BoxDecoration(
65+
gradient: Theme.brightnessOf(context) == Brightness.light
66+
? const LinearGradient(
67+
colors: [
68+
Color.fromARGB(229, 255, 255, 255),
69+
Color.fromARGB(0, 255, 255, 255),
70+
],
71+
begin: Alignment.topCenter,
72+
end: Alignment.bottomCenter,
73+
)
74+
: const LinearGradient(
75+
colors: [
76+
Color.fromARGB(234, 0, 0, 0),
77+
Color.fromARGB(137, 0, 0, 0),
78+
Color.fromARGB(0, 0, 0, 0),
79+
],
80+
begin: Alignment.topCenter,
81+
end: Alignment.bottomCenter,
82+
),
83+
)
84+
: null,
8185
child: UiKitView(
8286
viewType: 'adaptive_platform_ui/ios26_toolbar',
8387
creationParams: creationParams,

lib/src/widgets/ios26/ios26_scaffold.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class IOS26Scaffold extends StatefulWidget {
1515
this.leading,
1616
this.minimizeBehavior = TabBarMinimizeBehavior.automatic,
1717
this.enableBlur = true,
18+
this.enableToolbarGradient = true,
1819
required this.children,
1920
});
2021

@@ -24,6 +25,7 @@ class IOS26Scaffold extends StatefulWidget {
2425
final Widget? leading;
2526
final TabBarMinimizeBehavior minimizeBehavior;
2627
final bool enableBlur;
28+
final bool enableToolbarGradient;
2729
final List<Widget> children;
2830

2931
@override
@@ -169,6 +171,7 @@ class _IOS26ScaffoldState extends State<IOS26Scaffold>
169171
widget.actions![index].onPressed();
170172
}
171173
},
174+
enableGradient: widget.enableToolbarGradient,
172175
),
173176
),
174177
// Tab bar - only show if destinations exist

lib/src/widgets/ios26/ios26_scaffold_legacy.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class IOS26ScaffoldLegacy extends StatefulWidget {
1818
this.leading,
1919
this.minimizeBehavior = TabBarMinimizeBehavior.automatic,
2020
this.enableBlur = true,
21+
this.enableToolbarGradient = true,
2122
required this.children,
2223
});
2324

@@ -29,6 +30,7 @@ class IOS26ScaffoldLegacy extends StatefulWidget {
2930
final Widget? leading;
3031
final TabBarMinimizeBehavior minimizeBehavior;
3132
final bool enableBlur;
33+
final bool enableToolbarGradient;
3234
final List<Widget> children;
3335

3436
@override
@@ -146,6 +148,7 @@ class _IOS26ScaffoldLegacyState extends State<IOS26ScaffoldLegacy>
146148
widget.actions![index].onPressed();
147149
}
148150
},
151+
enableGradient: widget.enableToolbarGradient,
149152
),
150153
),
151154
// Tab bar - only show if destinations exist

0 commit comments

Comments
 (0)