fix(app): a phrase field keeps its focus as the app goes and comes back

SecretScreen built its child alone, and a stack around it with the cover
while the app was away (iOS), so each switch of apps built the child anew:
a phrase field lost its focus, its caret and what the keyboard was
composing (the short reading's L4). It always builds the stack now, laid
out as the child alone (StackFit.passthrough), the cover in it only while
away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-21 18:02:35 +02:00
commit 1ca4e083bb
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -108,18 +108,19 @@ class _SecretScreenState() extends State<SecretScreen> {
}
@override
Widget build(BuildContext context) {
if (!(_away && (widget.coversWhenAway ?? Platform.isIOS))) {
return widget.child;
}
return Stack(
children: [
widget.child,
Widget build(BuildContext context) => Stack(
// Always the stack, the cover in it only while away: [child] keeps its
// place in the tree, so a field in it keeps its focus and what the
// keyboard was composing as the app goes and comes back (the short
// reading's L4); laid out as without it.
fit: StackFit.passthrough,
children: [
widget.child,
if (_away && (widget.coversWhenAway ?? Platform.isIOS))
Positioned.fill(
key: SecretScreen.coverKey,
child: ColoredBox(color: Theme.of(context).colorScheme.surface),
),
],
);
}
],
);
}