Dropdowns in windows version keep auto scrolling back to top #391
This commit is contained in:
parent
779692bb87
commit
cc85f3f18f
|
|
@ -10,6 +10,7 @@ import 'package:flutter_redux/flutter_redux.dart';
|
|||
// Project imports:
|
||||
import 'package:invoiceninja_flutter/constants.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/task_model.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/app_border.dart';
|
||||
|
|
@ -36,7 +37,6 @@ class TaskEdit extends StatefulWidget {
|
|||
|
||||
class _TaskEditState extends State<TaskEdit>
|
||||
with SingleTickerProviderStateMixin {
|
||||
Timer _timer;
|
||||
TabController _controller;
|
||||
int _updatedAt = 0;
|
||||
|
||||
|
|
@ -50,9 +50,6 @@ class _TaskEditState extends State<TaskEdit>
|
|||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_timer = Timer.periodic(Duration(seconds: 1),
|
||||
(Timer t) => mounted ? setState(() => false) : false);
|
||||
|
||||
final index =
|
||||
widget.viewModel.taskTimeIndex != null ? kTimesScreen : kDetailsScreen;
|
||||
|
||||
|
|
@ -70,8 +67,6 @@ class _TaskEditState extends State<TaskEdit>
|
|||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer.cancel();
|
||||
_timer = null;
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
|
@ -81,11 +76,7 @@ class _TaskEditState extends State<TaskEdit>
|
|||
final localization = AppLocalization.of(context);
|
||||
final viewModel = widget.viewModel;
|
||||
final task = viewModel.task;
|
||||
|
||||
final state = viewModel.state;
|
||||
final useSidebarEditor =
|
||||
state.prefState.useSidebarEditor[EntityType.task] ?? false;
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final isFullscreen = state.prefState.isEditorFullScreen(EntityType.task);
|
||||
|
||||
return EditScaffold(
|
||||
|
|
@ -134,7 +125,69 @@ class _TaskEditState extends State<TaskEdit>
|
|||
],
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: BottomAppBar(
|
||||
bottomNavigationBar: _BottomBar(
|
||||
task: task,
|
||||
),
|
||||
floatingActionButton: task.isInvoiced || task.isDeleted
|
||||
? SizedBox()
|
||||
: FloatingActionButton(
|
||||
heroTag: 'task_edit_fab',
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
onPressed: () {
|
||||
viewModel.onFabPressed();
|
||||
setState(() {
|
||||
_updatedAt = DateTime.now().millisecondsSinceEpoch;
|
||||
});
|
||||
},
|
||||
child: Icon(
|
||||
task.isRunning ? Icons.stop : Icons.play_arrow,
|
||||
color: Colors.white,
|
||||
),
|
||||
tooltip: task.isRunning ? localization.stop : localization.start,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _BottomBar extends StatefulWidget {
|
||||
const _BottomBar({
|
||||
Key key,
|
||||
@required this.task,
|
||||
}) : super(key: key);
|
||||
|
||||
final TaskEntity task;
|
||||
|
||||
@override
|
||||
State<_BottomBar> createState() => _BottomBarState();
|
||||
}
|
||||
|
||||
class _BottomBarState extends State<_BottomBar> {
|
||||
Timer _timer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_timer = Timer.periodic(Duration(seconds: 1),
|
||||
(Timer t) => mounted ? setState(() => false) : false);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer.cancel();
|
||||
_timer = null;
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final localization = AppLocalization.of(context);
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final useSidebarEditor =
|
||||
state.prefState.useSidebarEditor[EntityType.task] ?? false;
|
||||
|
||||
return BottomAppBar(
|
||||
elevation: 0,
|
||||
color: Theme.of(context).cardColor,
|
||||
shape: CircularNotchedRectangle(),
|
||||
|
|
@ -171,16 +224,16 @@ class _TaskEditState extends State<TaskEdit>
|
|||
return localization.duration +
|
||||
' ' +
|
||||
formatNumber(
|
||||
task
|
||||
widget.task
|
||||
.calculateDuration(
|
||||
includeRunning: task.showAsRunning)
|
||||
includeRunning: widget.task.showAsRunning)
|
||||
.inSeconds
|
||||
.toDouble(),
|
||||
context,
|
||||
formatNumberType: FormatNumberType.duration);
|
||||
},
|
||||
style: TextStyle(
|
||||
color: viewModel.state.prefState.enableDarkMode
|
||||
color: state.prefState.enableDarkMode
|
||||
? Colors.white
|
||||
: Colors.black,
|
||||
fontSize: 20.0,
|
||||
|
|
@ -192,24 +245,6 @@ class _TaskEditState extends State<TaskEdit>
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: task.isInvoiced || task.isDeleted
|
||||
? SizedBox()
|
||||
: FloatingActionButton(
|
||||
heroTag: 'task_edit_fab',
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
onPressed: () {
|
||||
viewModel.onFabPressed();
|
||||
setState(() {
|
||||
_updatedAt = DateTime.now().millisecondsSinceEpoch;
|
||||
});
|
||||
},
|
||||
child: Icon(
|
||||
task.isRunning ? Icons.stop : Icons.play_arrow,
|
||||
color: Colors.white,
|
||||
),
|
||||
tooltip: task.isRunning ? localization.stop : localization.start,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue