reduce unneeded builds
This commit is contained in:
parent
ef8292b46c
commit
ae29fbd11a
6 changed files with 66 additions and 49 deletions
|
|
@ -421,7 +421,9 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
inputFocus = FocusNode(onKeyEvent: _customEnterKeyHandling);
|
||||
|
||||
scrollController.addListener(_updateScrollController);
|
||||
inputFocus.addListener(_inputFocusListener);
|
||||
// #Pangea
|
||||
// inputFocus.addListener(_inputFocusListener);
|
||||
// Pangea#
|
||||
|
||||
_loadDraft();
|
||||
WidgetsBinding.instance.addPostFrameCallback(_shareItems);
|
||||
|
|
@ -779,7 +781,9 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
void dispose() {
|
||||
timeline?.cancelSubscriptions();
|
||||
timeline = null;
|
||||
inputFocus.removeListener(_inputFocusListener);
|
||||
// #Pangea
|
||||
// inputFocus.removeListener(_inputFocusListener);
|
||||
// Pangea#
|
||||
onFocusSub?.cancel();
|
||||
//#Pangea
|
||||
choreographer.dispose();
|
||||
|
|
@ -1238,11 +1242,13 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
setState(() => showEmojiPicker = !showEmojiPicker);
|
||||
}
|
||||
|
||||
void _inputFocusListener() {
|
||||
if (showEmojiPicker && inputFocus.hasFocus) {
|
||||
setState(() => showEmojiPicker = false);
|
||||
}
|
||||
}
|
||||
// #Pangea
|
||||
// void _inputFocusListener() {
|
||||
// if (showEmojiPicker && inputFocus.hasFocus) {
|
||||
// setState(() => showEmojiPicker = false);
|
||||
// }
|
||||
// }
|
||||
// Pangea#
|
||||
|
||||
void sendLocationAction() async {
|
||||
await showAdaptiveDialog(
|
||||
|
|
|
|||
|
|
@ -427,9 +427,7 @@ class InputBar extends StatelessWidget {
|
|||
}
|
||||
|
||||
// #Pangea
|
||||
void onInputTap(BuildContext context, {required FocusNode fNode}) {
|
||||
fNode.requestFocus();
|
||||
|
||||
void onInputTap(BuildContext context) {
|
||||
// show the paywall if appropriate
|
||||
final choreographer = controller!.choreographer;
|
||||
if (MatrixState
|
||||
|
|
@ -525,12 +523,7 @@ class InputBar extends StatelessWidget {
|
|||
style: controller?.exceededMaxLength ?? false
|
||||
? const TextStyle(color: Colors.red)
|
||||
: null,
|
||||
onTap: () {
|
||||
onInputTap(
|
||||
context,
|
||||
fNode: focusNode,
|
||||
);
|
||||
},
|
||||
onTap: () => onInputTap(context),
|
||||
decoration: decoration!,
|
||||
onChanged: (text) {
|
||||
// fix for the library for now
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ class Choreographer extends ChangeNotifier {
|
|||
Timer? _debounceTimer;
|
||||
String? _lastChecked;
|
||||
ChoreoMode _choreoMode = ChoreoMode.igc;
|
||||
final ValueNotifier<String?> _sourceText = ValueNotifier(null);
|
||||
|
||||
StreamSubscription? _languageStream;
|
||||
StreamSubscription? _settingsUpdateStream;
|
||||
|
|
@ -62,8 +61,6 @@ class Choreographer extends ChangeNotifier {
|
|||
int get timesClicked => _timesClicked;
|
||||
ValueNotifier<bool> get isFetching => _isFetching;
|
||||
ChoreoMode get choreoMode => _choreoMode;
|
||||
|
||||
ValueNotifier<String?> get sourceText => _sourceText;
|
||||
String get currentText => textController.text;
|
||||
|
||||
void _initialize() {
|
||||
|
|
@ -96,8 +93,8 @@ class Choreographer extends ChangeNotifier {
|
|||
_timesClicked = 0;
|
||||
_isFetching.value = false;
|
||||
_choreoRecord = null;
|
||||
_sourceText.value = null;
|
||||
itController.clear();
|
||||
itController.clearSourceText();
|
||||
igc.clear();
|
||||
_resetDebounceTimer();
|
||||
}
|
||||
|
|
@ -250,8 +247,11 @@ class Choreographer extends ChangeNotifier {
|
|||
if (errorService.isError) return;
|
||||
|
||||
igc.clear();
|
||||
_resetDebounceTimer();
|
||||
if (textController.editType == EditType.keyboard) {
|
||||
itController.clearSourceText();
|
||||
}
|
||||
|
||||
_resetDebounceTimer();
|
||||
_debounceTimer ??= Timer(
|
||||
const Duration(milliseconds: ChoreoConstants.msBeforeIGCStart),
|
||||
() => _getLanguageAssistance(),
|
||||
|
|
@ -298,10 +298,11 @@ class Choreographer extends ChangeNotifier {
|
|||
final message = chatController.sendController.text;
|
||||
final fakeEventId = chatController.sendFakeMessage();
|
||||
final PangeaRepresentation? originalWritten =
|
||||
_choreoRecord?.includedIT == true && _sourceText.value != null
|
||||
_choreoRecord?.includedIT == true &&
|
||||
itController.sourceText.value != null
|
||||
? PangeaRepresentation(
|
||||
langCode: l1LangCode ?? LanguageKeys.unknownLanguage,
|
||||
text: _sourceText.value!,
|
||||
text: itController.sourceText.value!,
|
||||
originalWritten: true,
|
||||
originalSent: false,
|
||||
)
|
||||
|
|
@ -371,10 +372,8 @@ class Choreographer extends ChangeNotifier {
|
|||
chatController.inputFocus.unfocus();
|
||||
|
||||
setChoreoMode(ChoreoMode.it);
|
||||
_sourceText.value = textController.text;
|
||||
itController.openIT(textController.text);
|
||||
textController.setSystemText("", EditType.it);
|
||||
|
||||
itController.openIT();
|
||||
igc.clear();
|
||||
|
||||
_initChoreoRecord();
|
||||
|
|
@ -413,17 +412,12 @@ class Choreographer extends ChangeNotifier {
|
|||
notifyListeners();
|
||||
}
|
||||
|
||||
void setSourceText(String? text) {
|
||||
_sourceText.value = text;
|
||||
}
|
||||
|
||||
void setEditingSourceText(bool value) {
|
||||
itController.setEditing(value);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void submitSourceTextEdits(String text) {
|
||||
_sourceText.value = text;
|
||||
textController.setSystemText("", EditType.it);
|
||||
itController.onSubmitEdits();
|
||||
notifyListeners();
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ extension ChoregrapherUserSettingsExtension on Choreographer {
|
|||
AssistanceState get assistanceState {
|
||||
final isSubscribed = pangeaController.subscriptionController.isSubscribed;
|
||||
if (isSubscribed == false) return AssistanceState.noSub;
|
||||
if (currentText.isEmpty && sourceText.value == null) {
|
||||
if (currentText.isEmpty && itController.sourceText.value == null) {
|
||||
return AssistanceState.noMessage;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import 'choreographer.dart';
|
|||
|
||||
class ITController {
|
||||
final Choreographer _choreographer;
|
||||
final ValueNotifier<String?> _sourceText = ValueNotifier(null);
|
||||
|
||||
final ValueNotifier<ITStep?> _currentITStep = ValueNotifier(null);
|
||||
final Queue<Completer<ITStep>> _queue = Queue();
|
||||
|
|
@ -33,10 +34,9 @@ class ITController {
|
|||
|
||||
ValueNotifier<bool> get open => _open;
|
||||
ValueNotifier<bool> get editing => _editing;
|
||||
bool get dismissed => _dismissed;
|
||||
ValueNotifier<ITStep?> get currentITStep => _currentITStep;
|
||||
|
||||
ValueNotifier<String?> get _sourceText => _choreographer.sourceText;
|
||||
ValueNotifier<String?> get sourceText => _sourceText;
|
||||
bool get dismissed => _dismissed;
|
||||
|
||||
ITRequestModel _request(String textInput) {
|
||||
assert(_sourceText.value != null);
|
||||
|
|
@ -74,15 +74,20 @@ class ITController {
|
|||
_goldRouteTracker = null;
|
||||
|
||||
_choreographer.setChoreoMode(ChoreoMode.igc);
|
||||
_choreographer.setSourceText(null);
|
||||
}
|
||||
|
||||
void clearSourceText() {
|
||||
_sourceText.value = null;
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_currentITStep.dispose();
|
||||
_editing.dispose();
|
||||
_sourceText.dispose();
|
||||
}
|
||||
|
||||
void openIT() {
|
||||
void openIT(String sourceText) {
|
||||
_sourceText.value = sourceText;
|
||||
_open.value = true;
|
||||
continueIT();
|
||||
}
|
||||
|
|
@ -171,8 +176,7 @@ class ITController {
|
|||
}
|
||||
|
||||
Future<void> _initTranslationData() async {
|
||||
final String currentText = _choreographer.currentText;
|
||||
final res = await _safeRequest(currentText);
|
||||
final res = await _safeRequest("");
|
||||
if (_sourceText.value == null || !_open.value) return;
|
||||
if (res.isError || res.result?.goldContinuances == null) {
|
||||
_choreographer.errorService.setErrorAndLock(
|
||||
|
|
@ -189,7 +193,7 @@ class ITController {
|
|||
|
||||
_currentITStep.value = ITStep.fromResponse(
|
||||
sourceText: _sourceText.value!,
|
||||
currentText: currentText,
|
||||
currentText: "",
|
||||
responseModel: res.result!,
|
||||
storedGoldContinuances: _goldRouteTracker!.continuances,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class ITBarState extends State<ITBar> with SingleTickerProviderStateMixin {
|
|||
final TextEditingController _sourceTextController = TextEditingController();
|
||||
|
||||
Timer? _successTimer;
|
||||
bool _visible = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
@ -46,14 +47,8 @@ class ITBarState extends State<ITBar> with SingleTickerProviderStateMixin {
|
|||
vsync: this,
|
||||
);
|
||||
_animation = CurvedAnimation(parent: _controller, curve: Curves.easeInOut);
|
||||
_open.value ? _controller.forward() : _controller.reverse();
|
||||
_open.addListener(() {
|
||||
final nextText = _sourceText.value ?? widget.choreographer.currentText;
|
||||
if (_sourceTextController.text != nextText) {
|
||||
_sourceTextController.text = nextText;
|
||||
}
|
||||
_open.value ? _controller.forward() : _controller.reverse();
|
||||
});
|
||||
_openListener();
|
||||
_open.addListener(_openListener);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -61,10 +56,31 @@ class ITBarState extends State<ITBar> with SingleTickerProviderStateMixin {
|
|||
_controller.dispose();
|
||||
_sourceTextController.dispose();
|
||||
_successTimer?.cancel();
|
||||
_open.removeListener(_openListener);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
ValueNotifier<String?> get _sourceText => widget.choreographer.sourceText;
|
||||
void _openListener() {
|
||||
if (!mounted) return;
|
||||
|
||||
final nextText = _sourceText.value ?? widget.choreographer.currentText;
|
||||
if (_sourceTextController.text != nextText) {
|
||||
_sourceTextController.text = nextText;
|
||||
}
|
||||
|
||||
if (_open.value) {
|
||||
setState(() => _visible = true);
|
||||
_controller.forward();
|
||||
} else {
|
||||
_controller.reverse().then((value) {
|
||||
if (!mounted) return;
|
||||
setState(() => _visible = false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ValueNotifier<String?> get _sourceText =>
|
||||
widget.choreographer.itController.sourceText;
|
||||
ValueNotifier<bool> get _open => widget.choreographer.itController.open;
|
||||
|
||||
void _showFeedbackCard(
|
||||
|
|
@ -165,6 +181,10 @@ class ITBarState extends State<ITBar> with SingleTickerProviderStateMixin {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!_visible) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return AnimatedBuilder(
|
||||
animation: _animation,
|
||||
builder: (context, child) => SizeTransition(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue