|
@@ -54,7 +54,7 @@ class _HomePageState extends State<HomePage> {
|
|
|
|
|
|
@override
|
|
@override
|
|
void initState() {
|
|
void initState() {
|
|
- _textController.addListener(_applyFiltering);
|
|
|
|
|
|
+ _textController.addListener(_applyFilteringAndRefresh);
|
|
_loadCodes();
|
|
_loadCodes();
|
|
_streamSubscription = Bus.instance.on<CodesUpdatedEvent>().listen((event) {
|
|
_streamSubscription = Bus.instance.on<CodesUpdatedEvent>().listen((event) {
|
|
_loadCodes();
|
|
_loadCodes();
|
|
@@ -71,11 +71,11 @@ class _HomePageState extends State<HomePage> {
|
|
CodeStore.instance.getAllCodes().then((codes) {
|
|
CodeStore.instance.getAllCodes().then((codes) {
|
|
_codes = codes;
|
|
_codes = codes;
|
|
_hasLoaded = true;
|
|
_hasLoaded = true;
|
|
- _applyFiltering();
|
|
|
|
|
|
+ _applyFilteringAndRefresh();
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- void _applyFiltering() {
|
|
|
|
|
|
+ void _applyFilteringAndRefresh() {
|
|
if (_searchText.isNotEmpty && _showSearchBox) {
|
|
if (_searchText.isNotEmpty && _showSearchBox) {
|
|
final String val = _searchText.toLowerCase();
|
|
final String val = _searchText.toLowerCase();
|
|
_filteredCodes = _codes
|
|
_filteredCodes = _codes
|
|
@@ -96,7 +96,7 @@ class _HomePageState extends State<HomePage> {
|
|
void dispose() {
|
|
void dispose() {
|
|
_streamSubscription?.cancel();
|
|
_streamSubscription?.cancel();
|
|
_triggerLogoutEvent?.cancel();
|
|
_triggerLogoutEvent?.cancel();
|
|
- _textController.removeListener(_applyFiltering);
|
|
|
|
|
|
+ _textController.removeListener(_applyFilteringAndRefresh);
|
|
super.dispose();
|
|
super.dispose();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -110,6 +110,10 @@ class _HomePageState extends State<HomePage> {
|
|
);
|
|
);
|
|
if (code != null) {
|
|
if (code != null) {
|
|
CodeStore.instance.addCode(code);
|
|
CodeStore.instance.addCode(code);
|
|
|
|
+ // Focus the new code by searching
|
|
|
|
+ if (_codes.length > 2) {
|
|
|
|
+ _focusNewCode(code);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -169,7 +173,7 @@ class _HomePageState extends State<HomePage> {
|
|
controller: _textController,
|
|
controller: _textController,
|
|
onChanged: (val) {
|
|
onChanged: (val) {
|
|
_searchText = val;
|
|
_searchText = val;
|
|
- _applyFiltering();
|
|
|
|
|
|
+ _applyFilteringAndRefresh();
|
|
},
|
|
},
|
|
decoration: InputDecoration(
|
|
decoration: InputDecoration(
|
|
hintText: l10n.searchHint,
|
|
hintText: l10n.searchHint,
|
|
@@ -191,7 +195,7 @@ class _HomePageState extends State<HomePage> {
|
|
} else {
|
|
} else {
|
|
_searchText = _textController.text;
|
|
_searchText = _textController.text;
|
|
}
|
|
}
|
|
- _applyFiltering();
|
|
|
|
|
|
+ _applyFilteringAndRefresh();
|
|
},
|
|
},
|
|
);
|
|
);
|
|
},
|
|
},
|
|
@@ -306,11 +310,7 @@ class _HomePageState extends State<HomePage> {
|
|
final newCode = Code.fromRawData(link);
|
|
final newCode = Code.fromRawData(link);
|
|
getNextTotp(newCode);
|
|
getNextTotp(newCode);
|
|
CodeStore.instance.addCode(newCode);
|
|
CodeStore.instance.addCode(newCode);
|
|
- _showSearchBox = true;
|
|
|
|
- _textController.text = newCode.account;
|
|
|
|
- _searchText = newCode.account;
|
|
|
|
- _applyFiltering();
|
|
|
|
- setState(() {});
|
|
|
|
|
|
+ _focusNewCode(newCode);
|
|
} catch (e, s) {
|
|
} catch (e, s) {
|
|
showGenericErrorDialog(context: context);
|
|
showGenericErrorDialog(context: context);
|
|
_logger.severe("error while handling deeplink", e, s);
|
|
_logger.severe("error while handling deeplink", e, s);
|
|
@@ -318,6 +318,13 @@ class _HomePageState extends State<HomePage> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ void _focusNewCode(Code newCode) {
|
|
|
|
+ _showSearchBox = true;
|
|
|
|
+ _textController.text = newCode.account;
|
|
|
|
+ _searchText = newCode.account;
|
|
|
|
+ _applyFilteringAndRefresh();
|
|
|
|
+ }
|
|
|
|
+
|
|
Widget _getFab() {
|
|
Widget _getFab() {
|
|
return SpeedDial(
|
|
return SpeedDial(
|
|
icon: Icons.add,
|
|
icon: Icons.add,
|