From b990979e5a9a85998ab0ea5ce1a27f4d1c977614 Mon Sep 17 00:00:00 2001 From: duong2417 Date: Thu, 14 Nov 2024 12:23:18 +0700 Subject: [PATCH] delete print --- lib/_shared/button/button_with_popup.dart | 18 ++++++------------ lib/_shared/widgets/chat_bubble_widget.dart | 1 - .../app_settings/widgets/switch_button.dart | 1 - lib/features/chat/ui/public_chat_screen.dart | 2 -- .../translate_settings/trans_bloc.dart | 12 +++--------- .../widgets/translate_settings_button.dart | 8 ++------ lib/utils/local_shared_data.dart | 1 - lib/utils/my_translator.dart | 3 --- lib/utils/send_to_gemini.dart | 3 +-- 9 files changed, 12 insertions(+), 37 deletions(-) diff --git a/lib/_shared/button/button_with_popup.dart b/lib/_shared/button/button_with_popup.dart index 6f62980..3313a6d 100644 --- a/lib/_shared/button/button_with_popup.dart +++ b/lib/_shared/button/button_with_popup.dart @@ -2,43 +2,37 @@ import 'package:flutter/material.dart'; class ButtonWithPopup extends StatefulWidget { const ButtonWithPopup( - { - // required this.onChanged, - required this.items, - this.onTap, - required this.child}); - // final Function(T) onChanged; + {super.key, required this.items, this.onTap, required this.child}); final List> items; final Widget child; final Function()? onTap; + @override - _ButtonWithPopupState createState() => _ButtonWithPopupState(); + State> createState() => _ButtonWithPopupState(); } class _ButtonWithPopupState extends State> { String? selectedItem; + final LayerLink _layerLink = LayerLink(); void _onDropdownTap() async { - print('onDropdownTap'); // Khi đã có dữ liệu, hiển thị dropdown items if (widget.items.isNotEmpty) { - print('items không rỗng'); _showOverlay(); //ko do day } else { - print('items rỗng'); // MsgDialog.showError(msg: 'Không tải được dữ liệu!'); } } final GlobalKey _key = GlobalKey(); + OverlayEntry? _overlayEntry; + void _showOverlay() { - print('show overlay'); //null check final renderBox = _key.currentContext!.findRenderObject() as RenderBox; final size = renderBox.size; - print('size (dropdownNoFetchItems): $size'); final position = renderBox.localToGlobal(Offset.zero); // Tính chiều cao của popup dựa trên số lượng items diff --git a/lib/_shared/widgets/chat_bubble_widget.dart b/lib/_shared/widgets/chat_bubble_widget.dart index bf10732..b1b9839 100644 --- a/lib/_shared/widgets/chat_bubble_widget.dart +++ b/lib/_shared/widgets/chat_bubble_widget.dart @@ -57,7 +57,6 @@ class ChatBubble extends StatelessWidget { padding: const EdgeInsets.all(8.0), child: BlocBuilder(builder: (context, state) { if (!isMine && state is ChangeLangState) { - print('state: ${state.selectedLanguages}'); context.read().getTranslations( message: message, selectedLanguages: state.selectedLanguages, diff --git a/lib/features/app_settings/widgets/switch_button.dart b/lib/features/app_settings/widgets/switch_button.dart index 1fa48af..127efe3 100644 --- a/lib/features/app_settings/widgets/switch_button.dart +++ b/lib/features/app_settings/widgets/switch_button.dart @@ -36,7 +36,6 @@ class _MySwitchButtonState extends State { onChanged: (value) { setState(() { _toggle = value; - print(_toggle); }); widget.onChange?.call(value); }, diff --git a/lib/features/chat/ui/public_chat_screen.dart b/lib/features/chat/ui/public_chat_screen.dart index 2aa6526..1ed4ec8 100644 --- a/lib/features/chat/ui/public_chat_screen.dart +++ b/lib/features/chat/ui/public_chat_screen.dart @@ -39,8 +39,6 @@ class PublicChatScreen extends StatelessWidget { shrinkWrap: true, itemBuilder: (BuildContext context, QueryDocumentSnapshot doc) { - print( - 'build FirestoreListView:${doc.data().toString()}'); if (!doc.exists) { return const SizedBox.shrink(); } diff --git a/lib/features/translate_settings/trans_bloc.dart b/lib/features/translate_settings/trans_bloc.dart index 745914e..20d845c 100644 --- a/lib/features/translate_settings/trans_bloc.dart +++ b/lib/features/translate_settings/trans_bloc.dart @@ -59,7 +59,6 @@ class TransBloc extends Bloc { .get(); } Map translations = data.data() ?? {}; - print('translations: $translations'); List listLangSendToGemini = []; for (String lang in selectedLanguages) { bool hasTranslated = false; @@ -133,14 +132,12 @@ class TransBloc extends Bloc { You must return the translations in JSON format with language codes as keys, e.g: {"en": "English translation", "fr": "French translation"}'''; final chatSession = model.startChat(generationConfig: generationConfig); final result = await chatSession.sendMessage(Content.text(prompt)); - final jsonTranslated = result.text; - print( - 'translated json: $jsonTranslated'); // {"translations": {"en": "Hello, this is a test. I am Dương"}} + final jsonTranslated = result + .text; // {"translations": {"en": "Hello, this is a test. I am Dương"}} Map? translated; if (jsonTranslated != null) { translated = jsonDecode(jsonTranslated)['translations']; - print( - 'final result: $translated'); //{en: Hello, this is a test. I am Dương} +//{en: Hello, this is a test. I am Dương} } else { MessageDialog.showError('Gemini trả về phản hồi null'); } @@ -149,7 +146,6 @@ class TransBloc extends Bloc { FutureOr _onLoadHistoryLanguages( LoadHistoryLanguagesEvent event, Emitter emit) { - print('onLoadHistoryLanguages'); emitSafely(TransInit()); final listHistoryLanguages = _localSharedData.getListHistoryLanguages(); emitSafely( @@ -160,14 +156,12 @@ class TransBloc extends Bloc { extension on List { //tính luôn cả trường hợp giống nhau nhưng ko đúng thứ tự bool equal(List selectedLanguages) { - // if (this == null) return false; if (isEmpty || selectedLanguages.isEmpty) return false; for (String e in this) { if (!selectedLanguages.contains(e)) { return false; } } - print('equal: $selectedLanguages'); return true; } } diff --git a/lib/features/translate_settings/widgets/translate_settings_button.dart b/lib/features/translate_settings/widgets/translate_settings_button.dart index f6cf52b..50e5a99 100644 --- a/lib/features/translate_settings/widgets/translate_settings_button.dart +++ b/lib/features/translate_settings/widgets/translate_settings_button.dart @@ -21,7 +21,7 @@ class TranslateSettingsButton extends StatelessWidget { } void showSelectLang() { - List _getHistoryLanguages() { + List getHistoryLanguages() { return LocalSharedData().getListHistoryLanguages(); } @@ -38,16 +38,12 @@ void showSelectLang() { .map((e) => e.trim().toLowerCase()) .toList(); languages.removeWhere((e) => e.isEmpty); - print('languages: $languages'); - // if (languages.length > maxLanguages) { - // languages.sublist(0, maxLanguages); - // } context.read().add(SelectLanguageEvent( languages: languages, )); LocalSharedData().setChatLanguagesAndHistoryLanguages(languages); }, - fetchListHistoryLanguages: () async => _getHistoryLanguages(), + fetchListHistoryLanguages: () async => getHistoryLanguages(), ); }, ), diff --git a/lib/utils/local_shared_data.dart b/lib/utils/local_shared_data.dart index 2452285..3486de9 100644 --- a/lib/utils/local_shared_data.dart +++ b/lib/utils/local_shared_data.dart @@ -50,7 +50,6 @@ class LocalSharedData { List list = sharedPreferences.getStringList(keyListHistoryLanguages) ?? [defaultLanguageCode, 'en']; - print('getListHistoryLanguages: $list'); return list; } diff --git a/lib/utils/my_translator.dart b/lib/utils/my_translator.dart index 66819fe..0a4bae1 100644 --- a/lib/utils/my_translator.dart +++ b/lib/utils/my_translator.dart @@ -11,9 +11,6 @@ Future translate(String text, from: from)) .text; } catch (e) { - print('translate error: $e'); - // MessageDialog.showError("Không tìm thấy ngôn ngữ '$to'\n${e}", - // titleText: 'Dịch thất bại (dịch từ ngôn ngữ "$from")'); return "Không tìm thấy ngôn ngữ '$to' (dịch từ ngôn ngữ '$from')"; } } diff --git a/lib/utils/send_to_gemini.dart b/lib/utils/send_to_gemini.dart index fb9550d..14e273f 100644 --- a/lib/utils/send_to_gemini.dart +++ b/lib/utils/send_to_gemini.dart @@ -47,8 +47,7 @@ Future> sendToGenmini({ final chatSession = model.startChat(generationConfig: generationConfig); final result = await chatSession.sendMessage(Content.text(prompt)); final jsonTranslated = result.text; - print( - 'translated json: $jsonTranslated'); // {"translations": {"en": "Hello, this is a test. I am Dương"}} + // {"translations": {"en": "Hello, this is a test. I am Dương"}} Map? translated; if (jsonTranslated != null) { translated = jsonDecode(jsonTranslated)['translations'];