Add "copy all" button to the appbar
This commit is contained in:
parent
ee41dda65a
commit
50ae080841
@ -1,10 +1,12 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import 'package:gergle/api/commands.dart';
|
import 'package:gergle/api/commands.dart';
|
||||||
import 'package:gergle/player_ui/main.dart';
|
import 'package:gergle/player_ui/main.dart';
|
||||||
import 'package:gergle/state/connection_state_bloc.dart';
|
import 'package:gergle/state/connection_state_bloc.dart';
|
||||||
|
import 'package:gergle/state/player_state_bloc.dart';
|
||||||
|
|
||||||
class PlayerUIAppBar{
|
class PlayerUIAppBar{
|
||||||
static AppBar appbar(BuildContext context) {
|
static AppBar appbar(BuildContext context) {
|
||||||
@ -12,6 +14,27 @@ class PlayerUIAppBar{
|
|||||||
title: const Text('Gergle'),
|
title: const Text('Gergle'),
|
||||||
backgroundColor: Theme.of(context).primaryColor,
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
actions: [
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.copy_all),
|
||||||
|
onPressed: () {
|
||||||
|
final state = BlocProvider.of<PlayerStateBloc>(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(
|
DropdownMenu(
|
||||||
leadingIcon: const Icon(Icons.storage),
|
leadingIcon: const Icon(Icons.storage),
|
||||||
dropdownMenuEntries: const <DropdownMenuEntry<String?>>[
|
dropdownMenuEntries: const <DropdownMenuEntry<String?>>[
|
||||||
|
Loading…
Reference in New Issue
Block a user