feat: add progress bar to IT bar
This commit is contained in:
parent
e2716ccf47
commit
e28ee2031d
2 changed files with 35 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/l10n/l10n.dart';
|
import 'package:fluffychat/l10n/l10n.dart';
|
||||||
|
import 'package:fluffychat/pangea/analytics_summary/animated_progress_bar.dart';
|
||||||
import 'package:fluffychat/pangea/choreographer/choreo_constants.dart';
|
import 'package:fluffychat/pangea/choreographer/choreo_constants.dart';
|
||||||
import 'package:fluffychat/pangea/choreographer/choreographer.dart';
|
import 'package:fluffychat/pangea/choreographer/choreographer.dart';
|
||||||
import 'package:fluffychat/pangea/choreographer/it/completed_it_step_model.dart';
|
import 'package:fluffychat/pangea/choreographer/it/completed_it_step_model.dart';
|
||||||
|
|
@ -200,6 +201,7 @@ class ITBarState extends State<ITBar> with SingleTickerProviderStateMixin {
|
||||||
setEditing:
|
setEditing:
|
||||||
widget.choreographer.itController.setEditingSourceText,
|
widget.choreographer.itController.setEditingSourceText,
|
||||||
editing: widget.choreographer.itController.editing,
|
editing: widget.choreographer.itController.editing,
|
||||||
|
progress: widget.choreographer.itController.progress,
|
||||||
sourceTextController: _sourceTextController,
|
sourceTextController: _sourceTextController,
|
||||||
sourceText: _sourceText,
|
sourceText: _sourceText,
|
||||||
onSubmitEdits: (_) {
|
onSubmitEdits: (_) {
|
||||||
|
|
@ -267,6 +269,7 @@ class _ITBarHeader extends StatelessWidget {
|
||||||
final Function(bool) setEditing;
|
final Function(bool) setEditing;
|
||||||
|
|
||||||
final ValueNotifier<bool> editing;
|
final ValueNotifier<bool> editing;
|
||||||
|
final ValueNotifier<double> progress;
|
||||||
final TextEditingController sourceTextController;
|
final TextEditingController sourceTextController;
|
||||||
final ValueNotifier<String?> sourceText;
|
final ValueNotifier<String?> sourceText;
|
||||||
|
|
||||||
|
|
@ -274,6 +277,7 @@ class _ITBarHeader extends StatelessWidget {
|
||||||
required this.onClose,
|
required this.onClose,
|
||||||
required this.setEditing,
|
required this.setEditing,
|
||||||
required this.editing,
|
required this.editing,
|
||||||
|
required this.progress,
|
||||||
required this.onSubmitEdits,
|
required this.onSubmitEdits,
|
||||||
required this.sourceTextController,
|
required this.sourceTextController,
|
||||||
required this.sourceText,
|
required this.sourceText,
|
||||||
|
|
@ -316,8 +320,26 @@ class _ITBarHeader extends StatelessWidget {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
secondChild: Row(
|
secondChild: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
|
||||||
children: [
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
||||||
|
child: ValueListenableBuilder(
|
||||||
|
valueListenable: progress,
|
||||||
|
builder: (context, value, __) => AnimatedProgressBar(
|
||||||
|
height: 20.0,
|
||||||
|
widthPercent: value,
|
||||||
|
backgroundColor: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.surfaceContainerHighest,
|
||||||
|
barColor: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.primary
|
||||||
|
.withAlpha(180),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
onPressed: () => setEditing(true),
|
onPressed: () => setEditing(true),
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,14 @@ class ITController {
|
||||||
final ValueNotifier<ITStepModel?> _currentITStep = ValueNotifier(null);
|
final ValueNotifier<ITStepModel?> _currentITStep = ValueNotifier(null);
|
||||||
final ValueNotifier<bool> _open = ValueNotifier(false);
|
final ValueNotifier<bool> _open = ValueNotifier(false);
|
||||||
final ValueNotifier<bool> _editing = ValueNotifier(false);
|
final ValueNotifier<bool> _editing = ValueNotifier(false);
|
||||||
|
final ValueNotifier<double> _progress = ValueNotifier(0.0);
|
||||||
|
|
||||||
ITController(this.onError);
|
ITController(this.onError);
|
||||||
|
|
||||||
ValueNotifier<bool> get open => _open;
|
ValueNotifier<bool> get open => _open;
|
||||||
ValueNotifier<bool> get editing => _editing;
|
ValueNotifier<bool> get editing => _editing;
|
||||||
|
ValueNotifier<double> get progress => _progress;
|
||||||
|
|
||||||
ValueNotifier<ITStepModel?> get currentITStep => _currentITStep;
|
ValueNotifier<ITStepModel?> get currentITStep => _currentITStep;
|
||||||
ValueNotifier<String?> get sourceText => _sourceText;
|
ValueNotifier<String?> get sourceText => _sourceText;
|
||||||
StreamController<CompletedITStepModel> acceptedContinuanceStream =
|
StreamController<CompletedITStepModel> acceptedContinuanceStream =
|
||||||
|
|
@ -142,6 +145,15 @@ class ITController {
|
||||||
chosen: chosenIndex,
|
chosen: chosenIndex,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
final progress = (_goldRouteTracker!.continuances.indexWhere(
|
||||||
|
(c) =>
|
||||||
|
c.text ==
|
||||||
|
_currentITStep.value!.continuances[chosenIndex].text,
|
||||||
|
) +
|
||||||
|
1) /
|
||||||
|
_goldRouteTracker!.continuances.length;
|
||||||
|
debugPrint("Progress updated to $progress");
|
||||||
|
_progress.value = progress;
|
||||||
_continueIT();
|
_continueIT();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue