Line data Source code
1 : // Copyright 2023 The terCAD team. All rights reserved.
2 : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
3 :
4 : import 'package:app_finance/_classes/controller/focus_controller.dart';
5 : import 'package:app_finance/design/wrapper/focus_wrapper.dart';
6 : import 'package:material_ui/material_ui.dart';
7 :
8 : abstract class AbstractSelector extends StatefulWidget {
9 : final dynamic value;
10 :
11 4 : const AbstractSelector({super.key, this.value});
12 : }
13 :
14 : abstract class AbstractSelectorState<T extends AbstractSelector> extends State<T> {
15 : late FocusNode focus;
16 : late FocusController focusController;
17 : final textController = SearchController();
18 :
19 4 : @override
20 : void dispose() {
21 8 : textController.dispose();
22 4 : super.dispose();
23 : }
24 :
25 : void onTap(BuildContext context);
26 :
27 : Widget buildContent(BuildContext context);
28 :
29 4 : @override
30 : Widget build(BuildContext context) {
31 10 : focusController = FocusWrapper.of(context) ?? FocusController();
32 20 : focus = focusController.bind(this, context: context, value: widget.value);
33 4 : return Focus(
34 12 : autofocus: mounted && focusController.isFocused(this) && widget.value == null,
35 4 : child: buildContent(context),
36 : );
37 : }
38 : }
|