Skip to content

Commit 8236855

Browse files
committed
use elevated button theme with optional color parameter for share button
"
1 parent 3f2a855 commit 8236855

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

lib/src/widgets/grant_permission_ui.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class GrantPermissionUi extends StatefulWidget {
7979
this.resourceNames,
8080
this.isFile = true,
8181
this.dataFilesMap = const {},
82+
this.shareButtonColor,
8283
this.customAppBar,
8384
this.onPermissionGranted,
8485
this.onNavigateBack,
@@ -168,6 +169,11 @@ class GrantPermissionUi extends StatefulWidget {
168169
169170
final Map<String, dynamic> dataFilesMap;
170171

172+
/// Optional background color for the Share Resource button.
173+
/// When provided, it overrides the theme's elevated button background.
174+
175+
final Color? shareButtonColor;
176+
171177
/// App specific app bar
172178
173179
final PreferredSizeWidget? customAppBar;

lib/src/widgets/grant_permission_ui_state.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ class GrantPermissionUiState extends State<GrantPermissionUi>
363363
onPermissionGranted: widget.onPermissionGranted,
364364
showFullPath: _showFullPath,
365365
onShowFullPathChanged: (v) => setState(() => _showFullPath = v),
366+
shareButtonColor: widget.shareButtonColor,
366367
),
367368
// Separator between Sharing and Permissions sections
368369
const Divider(),

lib/src/widgets/share_resource_button.dart

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ class ShareResourceButton extends StatefulWidget {
118118
119119
final ValueChanged<bool>? onShowFullPathChanged;
120120

121+
/// Optional background color for the Share Resource button.
122+
/// When provided, overrides the theme's elevated button background.
123+
124+
final Color? shareButtonColor;
125+
121126
const ShareResourceButton({
122127
super.key,
123128
required this.fileNameController,
@@ -134,6 +139,7 @@ class ShareResourceButton extends StatefulWidget {
134139
this.onShowFullPathChanged,
135140
this.dataFilesMap = const {},
136141
this.onPermissionGranted,
142+
this.shareButtonColor,
137143
});
138144

139145
@override
@@ -201,13 +207,13 @@ class _ShareResourceButtonState extends State<ShareResourceButton> {
201207
mainAxisAlignment: MainAxisAlignment.end,
202208
spacing: 5,
203209
children: [
210+
// Show full path switch
204211
if (widget.resourceNames != null || widget.resourceName != null) ...[
205212
const Text(
206213
'Show\nFull Path',
207214
maxLines: 2,
208215
overflow: TextOverflow.ellipsis,
209216
textAlign: TextAlign.end,
210-
// style: TextStyle(fontSize: 12, color: Colors.grey.shade700),
211217
),
212218
Switch(
213219
value: widget.showFullPath,
@@ -219,8 +225,20 @@ class _ShareResourceButtonState extends State<ShareResourceButton> {
219225
onChanged: widget.onShowFullPathChanged,
220226
),
221227
],
228+
// Share Resource/s button
222229
ElevatedButton.icon(
223230
icon: const Icon(Icons.share),
231+
// Set share button background color to
232+
// parameter shareButtonColor or
233+
// theme elevated button color
234+
// or elevated button default (grey)
235+
style: widget.shareButtonColor != null
236+
? Theme.of(context).elevatedButtonTheme.style?.copyWith(
237+
backgroundColor: WidgetStateProperty.all<Color>(
238+
widget.shareButtonColor!,
239+
),
240+
)
241+
: Theme.of(context).elevatedButtonTheme.style,
224242
onPressed: () async {
225243
// Assign dataFile if null (first Grant press)
226244
_resourceName = widget.resourceName ?? _fileNameController.text;

0 commit comments

Comments
 (0)