chore: clean up vocab analytics details popup
This commit is contained in:
parent
daeaf900f3
commit
7756f2fe9f
4 changed files with 28 additions and 130 deletions
|
|
@ -1,4 +1,13 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pangea/common/config/environment.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
|
|
@ -6,14 +15,6 @@ import 'package:fluffychat/pangea/common/utils/firebase_analytics.dart';
|
|||
import 'package:fluffychat/pangea/learning_settings/utils/p_language_store.dart';
|
||||
import 'package:fluffychat/utils/client_manager.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'config/setting_keys.dart';
|
||||
import 'utils/background_push.dart';
|
||||
import 'widgets/fluffy_chat_app.dart';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/analytics_details_popup/analytics_details_popup_content.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/construct_use_model.dart';
|
||||
|
|
@ -9,10 +12,10 @@ import 'package:fluffychat/pangea/morphs/get_grammar_copy.dart';
|
|||
import 'package:fluffychat/pangea/morphs/morph_features_enum.dart';
|
||||
import 'package:fluffychat/pangea/morphs/morph_icon.dart';
|
||||
import 'package:fluffychat/pangea/phonetic_transcription/phonetic_transcription_widget.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/utils/shrinkable_text.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/practice_activity/word_text_with_audio_button.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/word_zoom/lemma_meaning_widget.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Displays information about selected lemma, and its usage
|
||||
class VocabDetailsView extends StatelessWidget {
|
||||
|
|
@ -52,16 +55,17 @@ class VocabDetailsView extends StatelessWidget {
|
|||
|
||||
return AnalyticsDetailsViewContent(
|
||||
title: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
WordTextWithAudioButton(
|
||||
text: _construct.lemma,
|
||||
style: Theme.of(context).textTheme.headlineLarge?.copyWith(
|
||||
color: textColor,
|
||||
),
|
||||
iconSize: _iconSize,
|
||||
uniqueID: "${_construct.lemma}-${_construct.category}",
|
||||
langCode: _userL2!,
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return ShrinkableText(
|
||||
text: _construct.lemma,
|
||||
maxWidth: constraints.maxWidth - 40.0,
|
||||
style: Theme.of(context).textTheme.headlineLarge?.copyWith(
|
||||
color: textColor,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
if (MatrixState.pangeaController.languageController.userL2 != null)
|
||||
Padding(
|
||||
|
|
@ -81,12 +85,6 @@ class VocabDetailsView extends StatelessWidget {
|
|||
),
|
||||
subtitle: Column(
|
||||
children: [
|
||||
if (_userL1 != null && _userL2 != null)
|
||||
PhoneticTranscription(
|
||||
text: _construct.lemma,
|
||||
l1: _userL1!,
|
||||
l2: _userL2!,
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 8.0,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/constants/language_constants.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/enums/l2_support_enum.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LanguageModel {
|
||||
final String langCode;
|
||||
|
|
|
|||
|
|
@ -1,36 +1,7 @@
|
|||
<<<<<<< Updated upstream
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/phonetic_transcription/phonetic_transcription_repo.dart';
|
||||
import 'package:fluffychat/pangea/phonetic_transcription/phonetic_transcription_request.dart';
|
||||
import 'package:fluffychat/pangea/phonetic_transcription/phonetic_transcription_response.dart';
|
||||
|
||||
class PhoneticTranscription extends StatefulWidget {
|
||||
final String text;
|
||||
final String l1;
|
||||
final String l2;
|
||||
|
||||
const PhoneticTranscription({
|
||||
super.key,
|
||||
required this.text,
|
||||
required this.l1,
|
||||
required this.l2,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PhoneticTranscription> createState() => PhoneticTranscriptionState();
|
||||
}
|
||||
|
||||
class PhoneticTranscriptionState extends State<PhoneticTranscription> {
|
||||
bool _loading = false;
|
||||
String? error;
|
||||
|
||||
PhoneticTranscriptionResponse? _response;
|
||||
=======
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/events/models/pangea_token_text_model.dart';
|
||||
|
|
@ -39,7 +10,6 @@ import 'package:fluffychat/pangea/phonetic_transcription/phonetic_transcription_
|
|||
import 'package:fluffychat/pangea/phonetic_transcription/phonetic_transcription_request.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/controllers/tts_controller.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PhoneticTranscriptionWidget extends StatefulWidget {
|
||||
final String text;
|
||||
|
|
@ -67,53 +37,10 @@ class _PhoneticTranscriptionWidgetState
|
|||
bool _isPlaying = false;
|
||||
bool _isLoading = false;
|
||||
late final StreamSubscription _loadingChoreoSubscription;
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
<<<<<<< Updated upstream
|
||||
_fetchPhoneticTranscription();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant PhoneticTranscription oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.text != widget.text ||
|
||||
oldWidget.l1 != widget.l1 ||
|
||||
oldWidget.l2 != widget.l2) {
|
||||
_fetchPhoneticTranscription();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _fetchPhoneticTranscription() async {
|
||||
final PhoneticTranscriptionRequest request = PhoneticTranscriptionRequest(
|
||||
l1: widget.l1,
|
||||
l2: widget.l2,
|
||||
content: widget.text,
|
||||
);
|
||||
|
||||
try {
|
||||
setState(() {
|
||||
_loading = true;
|
||||
error = null;
|
||||
});
|
||||
|
||||
_response = await PhoneticTranscriptionRepo.get(request);
|
||||
} catch (e, s) {
|
||||
ErrorHandler.logError(
|
||||
e: e,
|
||||
s: s,
|
||||
data: request.toJson(),
|
||||
);
|
||||
error = e.toString();
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
});
|
||||
}
|
||||
=======
|
||||
_transcriptionFuture = _fetchTranscription();
|
||||
_loadingChoreoSubscription =
|
||||
TtsController.loadingChoreoStream.stream.listen((val) {
|
||||
|
|
@ -169,39 +96,11 @@ class _PhoneticTranscriptionWidgetState
|
|||
if (mounted) setState(() => _isPlaying = false);
|
||||
},
|
||||
);
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
<<<<<<< Updated upstream
|
||||
if (error != null) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.error_outline,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
size: 16.0,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
L10n.of(context).phoneticTranscriptionError,
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
if (_loading || _response == null) {
|
||||
return const Center(child: CircularProgressIndicator.adaptive());
|
||||
}
|
||||
|
||||
return Text(
|
||||
'Phonetic transcription for "${widget.text}" in ${widget.l2}',
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
=======
|
||||
return FutureBuilder<String?>(
|
||||
future: _transcriptionFuture,
|
||||
builder: (context, snapshot) {
|
||||
|
|
@ -224,7 +123,7 @@ class _PhoneticTranscriptionWidgetState
|
|||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
transcription.isNotEmpty ? transcription : widget.text,
|
||||
"/${transcription.isNotEmpty ? transcription : widget.text}/",
|
||||
style:
|
||||
widget.style ?? Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
|
|
@ -253,7 +152,6 @@ class _PhoneticTranscriptionWidgetState
|
|||
),
|
||||
);
|
||||
},
|
||||
>>>>>>> Stashed changes
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue