From 50ae0808414dcf5a08bc7c9c887c97f1c7e5faf6 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Thu, 19 Dec 2024 12:25:28 +0100 Subject: [PATCH] Add "copy all" button to the appbar --- lib/player_ui/app_bar.dart | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/player_ui/app_bar.dart b/lib/player_ui/app_bar.dart index 173ea1f..7f450df 100644 --- a/lib/player_ui/app_bar.dart +++ b/lib/player_ui/app_bar.dart @@ -1,10 +1,12 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:gergle/api/commands.dart'; import 'package:gergle/player_ui/main.dart'; import 'package:gergle/state/connection_state_bloc.dart'; +import 'package:gergle/state/player_state_bloc.dart'; class PlayerUIAppBar{ static AppBar appbar(BuildContext context) { @@ -12,6 +14,27 @@ class PlayerUIAppBar{ title: const Text('Gergle'), backgroundColor: Theme.of(context).primaryColor, actions: [ + IconButton( + icon: const Icon(Icons.copy_all), + onPressed: () { + final state = BlocProvider.of(context).state; + if (state != null) { + final uris = state.playlist + .map((e) => e.filename) + .where((f) => f != '/tmp/the_man.png') + .join('\n'); + if (uris.isNotEmpty) { + Clipboard.setData(ClipboardData(text: uris)); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Copied playlist to clipboard'), + duration: Duration(milliseconds: 500), + ), + ); + } + } + }, + ), DropdownMenu( leadingIcon: const Icon(Icons.storage), dropdownMenuEntries: const >[