Skip to content

Commit

Permalink
feat: copy lyrics to clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Jan 21, 2024
1 parent ed02698 commit 715b75b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
3 changes: 3 additions & 0 deletions lib/controller/navigator_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ void snackyy({
Color? leftBarIndicatorColor,
Widget? button,
bool? isError,
int? maxLinesMessage,
}) {
isError ??= title == lang.ERROR;
Get.showSnackbar(
Expand All @@ -481,6 +482,8 @@ void snackyy({
messageText: Text(
message,
style: title != '' ? Get.textTheme.displaySmall : Get.textTheme.displayMedium,
maxLines: maxLinesMessage,
overflow: TextOverflow.ellipsis,
),
mainButton: button,
margin: margin,
Expand Down
1 change: 1 addition & 0 deletions lib/core/translations/keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ abstract class LanguageKeys {
String get CONFIGURE => _getKey('CONFIGURE');
String get CONFIRM => _getKey('CONFIRM');
String get COPIED_ARTWORK => _getKey('COPIED_ARTWORK');
String get COPIED_TO_CLIPBOARD => _getKey('COPIED_TO_CLIPBOARD');
String get COPY => _getKey('COPY');
String get CORRUPTED_FILE => _getKey('CORRUPTED_FILE');
String get COULDNT_OPEN_YT_LINK => _getKey('COULDNT_OPEN_YT_LINK');
Expand Down
34 changes: 29 additions & 5 deletions lib/ui/dialogs/set_lrc_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import 'dart:async';
import 'dart:io';

import 'package:file_picker/file_picker.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:lrc/lrc.dart';

import 'package:namida/class/lyrics.dart';
import 'package:namida/class/track.dart';
import 'package:namida/controller/current_color.dart';
import 'package:namida/controller/lyrics_controller.dart';
import 'package:namida/controller/navigator_controller.dart';
import 'package:namida/controller/player_controller.dart';
Expand Down Expand Up @@ -315,6 +317,7 @@ void showLRCSetDialog(Track track, Color colorScheme) async {
},
colorScheme: colorScheme,
dialogBuilder: (theme) => CustomBlurryDialog(
insetPadding: const EdgeInsets.symmetric(horizontal: 38.0, vertical: 32.0),
title: lang.LYRICS,
actions: [
NamidaButton(
Expand Down Expand Up @@ -394,12 +397,33 @@ void showLRCSetDialog(Track track, Color colorScheme) async {
children: [
Icon(l.file == null ? Broken.document_download : Broken.document, size: 18.0),
const SizedBox(width: 8.0),
Text(
cacheText != '' ? "$syncedText ($cacheText)" : syncedText,
style: Get.textTheme.displayMedium,
Expanded(
child: Text(
cacheText != '' ? "$syncedText ($cacheText)" : syncedText,
style: Get.textTheme.displayMedium,
),
),
NamidaIconButton(
horizontalPadding: 0.0,
tooltip: lang.COPY,
icon: Broken.copy,
iconSize: 20.0,
onPressed: () {
final text = l.lyrics;
Clipboard.setData(ClipboardData(text: text));
snackyy(
title: lang.COPIED_TO_CLIPBOARD,
message: text.replaceAll('\n', ' '),
maxLinesMessage: 2,
leftBarIndicatorColor: CurrentColor.inst.color,
margin: EdgeInsets.zero,
top: false,
borderRadius: 0,
);
},
),
const SizedBox(width: 6.0),
if (l.file != null) ...[
const Spacer(),
if (l.synced && !l.fromInternet)
NamidaIconButton(
horizontalPadding: 0.0,
Expand All @@ -409,7 +433,7 @@ void showLRCSetDialog(Track track, Color colorScheme) async {
showEditCachedSyncedTimeOffsetDialog(l);
},
),
const SizedBox(width: 8.0),
const SizedBox(width: 6.0),
NamidaIconButton(
horizontalPadding: 0.0,
icon: Broken.trash,
Expand Down

0 comments on commit 715b75b

Please sign in to comment.