Skip to content

Commit

Permalink
feat: move list of transcripts to extended entry actions & improve
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasn committed Nov 17, 2024
1 parent 45b8d9e commit 8d285f0
Show file tree
Hide file tree
Showing 5 changed files with 240 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:lotti/features/journal/ui/widgets/entry_details/delete_icon_widg
import 'package:lotti/features/journal/ui/widgets/entry_details/save_button.dart';
import 'package:lotti/features/journal/ui/widgets/entry_details/share_button_widget.dart';
import 'package:lotti/features/journal/ui/widgets/tags/tag_add.dart';
import 'package:lotti/features/speech/ui/widgets/speech_modal.dart';
import 'package:lotti/get_it.dart';
import 'package:lotti/l10n/app_localizations_context.dart';
import 'package:lotti/services/link_service.dart';
Expand Down Expand Up @@ -211,6 +212,7 @@ class ExtendedHeaderActions {
entryId: entryId,
beamBack: !inLinkedEntries,
),
SpeechModalListTile(entryId: entryId),
ShareButtonListTile(entryId: entryId),
TagAddListTile(entryId: entryId),
ListTile(
Expand Down
129 changes: 0 additions & 129 deletions lib/features/speech/ui/widgets/audio_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:lotti/classes/journal_entities.dart';
import 'package:lotti/features/journal/state/entry_controller.dart';
import 'package:lotti/features/journal/util/entry_tools.dart';
import 'package:lotti/features/speech/state/asr_service.dart';
import 'package:lotti/features/speech/state/player_cubit.dart';
import 'package:lotti/features/speech/state/player_state.dart';
import 'package:lotti/features/speech/ui/widgets/transcription_progress_modal.dart';
import 'package:lotti/get_it.dart';
import 'package:lotti/logic/persistence_logic.dart';
import 'package:lotti/themes/theme.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';

class AudioPlayerWidget extends ConsumerWidget {
const AudioPlayerWidget(this.journalAudio, {super.key});
Expand Down Expand Up @@ -50,7 +47,6 @@ class AudioPlayerWidget extends ConsumerWidget {
builder: (BuildContext context, AudioPlayerState state) {
final isActive = state.audioNote?.meta.id == journalAudio.meta.id;
final cubit = context.read<AudioPlayerCubit>();
final transcripts = journalAudio.data.transcripts;

return Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down Expand Up @@ -127,14 +123,6 @@ class AudioPlayerWidget extends ConsumerWidget {
..emitState();
},
),
if (transcripts?.isNotEmpty ?? false)
IconButton(
icon: const Icon(Icons.list),
iconSize: 20,
tooltip: 'Show Transcriptions',
color: context.colorScheme.outline,
onPressed: cubit.toggleTranscriptsList,
),
],
),
Row(
Expand All @@ -159,126 +147,9 @@ class AudioPlayerWidget extends ConsumerWidget {
),
],
),
if ((transcripts?.isNotEmpty ?? false) && state.showTranscriptsList)
Column(
children: [
const SizedBox(height: 10),
...transcripts!.map(
(transcript) => TranscriptListItem(
transcript,
entryId: journalAudio.meta.id,
),
),
],
),
],
);
},
);
}
}

class TranscriptListItem extends StatefulWidget {
const TranscriptListItem(
this.transcript, {
required this.entryId,
super.key,
});

final String entryId;
final AudioTranscript transcript;

@override
State<TranscriptListItem> createState() => _TranscriptListItemState();
}

class _TranscriptListItemState extends State<TranscriptListItem> {
bool show = false;

void toggleShow() {
setState(() {
show = !show;
});
}

@override
Widget build(BuildContext context) {
return Card(
color: context.colorScheme.primaryContainer,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 15,
),
child: Column(
children: [
MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: toggleShow,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.min,
children: [
Text(
dfShorter.format(widget.transcript.created),
style: transcriptHeaderStyle,
),
const SizedBox(width: 10),
Text(
formatSeconds(widget.transcript.processingTime),
style: transcriptHeaderStyle,
),
const SizedBox(width: 10),
Text(
'Lang: ${widget.transcript.detectedLanguage}',
style: transcriptHeaderStyle,
),
const SizedBox(width: 10),
Text(
'${widget.transcript.library}, '
' ${widget.transcript.model}',
style: transcriptHeaderStyle,
),
const SizedBox(width: 10),
Opacity(
opacity: show ? 1 : 0,
child: IconButton(
onPressed: () {
getIt<PersistenceLogic>().removeAudioTranscript(
journalEntityId: widget.entryId,
transcript: widget.transcript,
);
},
icon: Icon(
MdiIcons.trashCanOutline,
size: fontSizeMedium,
),
),
),
if (show)
const Icon(
Icons.keyboard_double_arrow_up_outlined,
size: fontSizeMedium,
)
else
const Icon(
Icons.keyboard_double_arrow_down_outlined,
size: fontSizeMedium,
),
],
),
),
),
if (show)
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: SelectableText(
widget.transcript.transcript,
),
),
],
),
),
);
}
}
Loading

0 comments on commit 8d285f0

Please sign in to comment.