fix(auth): don't make app unusable on error

This commit is contained in:
Prateek Sunal 2024-05-06 21:08:39 +05:30
parent 68f0a1d259
commit 62441b86bd
2 changed files with 23 additions and 32 deletions

View file

@ -28,12 +28,10 @@ import 'package:move_to_background/move_to_background.dart';
class CodeWidget extends StatefulWidget {
final Code code;
final bool hasError;
const CodeWidget(
this.code, {
super.key,
this.hasError = false,
});
@override
@ -92,11 +90,7 @@ class _CodeWidgetState extends State<CodeWidget> {
_isInitialized = true;
}
final l10n = context.l10n;
return IgnorePointer(
ignoring: widget.hasError,
child: Opacity(
opacity: widget.hasError ? 0.5 : 1.0,
child: Container(
return Container(
margin: const EdgeInsets.only(left: 16, right: 16, bottom: 8, top: 8),
child: Builder(
builder: (context) {
@ -230,8 +224,8 @@ class _CodeWidgetState extends State<CodeWidget> {
);
},
),
),
),
);
}

View file

@ -253,32 +253,30 @@ class _HomePageState extends State<HomePage> {
),
centerTitle: true,
actions: <Widget>[
if (_allCodes?.state == AllCodesState.value)
IconButton(
icon: _showSearchBox
? const Icon(Icons.clear)
: const Icon(Icons.search),
tooltip: l10n.search,
onPressed: () {
setState(
() {
_showSearchBox = !_showSearchBox;
if (!_showSearchBox) {
_textController.clear();
_searchText = "";
} else {
_searchText = _textController.text;
}
_applyFilteringAndRefresh();
},
);
},
),
IconButton(
icon: _showSearchBox
? const Icon(Icons.clear)
: const Icon(Icons.search),
tooltip: l10n.search,
onPressed: () {
setState(
() {
_showSearchBox = !_showSearchBox;
if (!_showSearchBox) {
_textController.clear();
_searchText = "";
} else {
_searchText = _textController.text;
}
_applyFilteringAndRefresh();
},
);
},
),
],
),
floatingActionButton: !_hasLoaded ||
(_allCodes?.codes.isEmpty ?? true) ||
_allCodes?.state == AllCodesState.error ||
!PreferenceService.instance.hasShownCoachMark()
? null
: _getFab(),
@ -361,7 +359,6 @@ class _HomePageState extends State<HomePage> {
return ClipRect(
child: CodeWidget(
_filteredCodes[newIndex],
hasError: _allCodes?.state == AllCodesState.error,
),
);
}),