Skip to content

Commit fed725d

Browse files
committed
Add panel background to unsafe area
1 parent 972a788 commit fed725d

File tree

3 files changed

+84
-65
lines changed

3 files changed

+84
-65
lines changed

lib/app/logging.dart

Lines changed: 62 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,15 @@ class LogPanelVisibilityNotifier extends StateNotifier<bool> {
118118
}
119119
}
120120

121-
class LoggingPanel extends ConsumerStatefulWidget {
122-
const LoggingPanel({super.key});
121+
class _LoggingPanel extends ConsumerStatefulWidget {
122+
final bool safeArea;
123+
const _LoggingPanel({this.safeArea = false});
123124

124125
@override
125-
ConsumerState<LoggingPanel> createState() => _LoggingPanelState();
126+
ConsumerState<_LoggingPanel> createState() => _LoggingPanelState();
126127
}
127128

128-
class _LoggingPanelState extends ConsumerState<LoggingPanel> {
129+
class _LoggingPanelState extends ConsumerState<_LoggingPanel> {
129130
bool _runningDiagnostics = false;
130131

131132
List<Widget> _buildChipsList(Level logLevel) {
@@ -217,14 +218,10 @@ class _LoggingPanelState extends ConsumerState<LoggingPanel> {
217218
final logLevel = ref.watch(logLevelProvider);
218219
final sensitiveLogs = ref.watch(
219220
logLevelProvider.select((level) => level.value <= Level.CONFIG.value));
220-
final visible = ref.watch(logPanelVisibilityProvider);
221-
222-
if (!visible) {
223-
return const SizedBox();
224-
}
225221

226222
return _Panel(
227223
sensitive: sensitiveLogs,
224+
safeArea: widget.safeArea,
228225
child: Wrap(
229226
alignment: WrapAlignment.spaceBetween,
230227
runSpacing: 4.0,
@@ -269,43 +266,40 @@ class _LoggingPanelState extends ConsumerState<LoggingPanel> {
269266
}
270267
}
271268

272-
class WarningPanel extends ConsumerWidget {
273-
const WarningPanel({super.key});
269+
class _WarningPanel extends StatelessWidget {
270+
final bool safeArea;
271+
const _WarningPanel({this.safeArea = false});
274272

275273
@override
276-
Widget build(BuildContext context, WidgetRef ref) {
274+
Widget build(BuildContext context) {
277275
final l10n = AppLocalizations.of(context);
278-
final allowScreenshots =
279-
isAndroid ? ref.watch(androidAllowScreenshotsProvider) : false;
280-
281-
if (!allowScreenshots) {
282-
return SizedBox();
283-
}
284276

285277
return _Panel(
286-
sensitive: allowScreenshots,
287-
child: Row(
288-
mainAxisSize: MainAxisSize.min,
289-
children: [
290-
Padding(
291-
padding: const EdgeInsets.only(left: 12.0, top: 8.0, bottom: 8.0),
292-
child: Icon(
293-
Symbols.warning_amber,
294-
size: 24,
278+
sensitive: true,
279+
safeArea: safeArea,
280+
child: Row(
281+
mainAxisSize: MainAxisSize.min,
282+
children: [
283+
Padding(
284+
padding: const EdgeInsets.only(left: 12.0, top: 8.0, bottom: 8.0),
285+
child: Icon(
286+
Symbols.warning_amber,
287+
size: 24,
288+
),
295289
),
296-
),
297-
const SizedBox(width: 8.0),
298-
Flexible(child: Text(l10n.l_warning_allow_screenshots))
299-
],
300-
),
301-
);
290+
const SizedBox(width: 8.0),
291+
Flexible(child: Text(l10n.l_warning_allow_screenshots))
292+
],
293+
));
302294
}
303295
}
304296

305297
class _Panel extends StatelessWidget {
306298
final Widget child;
307299
final bool sensitive;
308-
const _Panel({required this.child, required this.sensitive});
300+
final bool safeArea;
301+
const _Panel(
302+
{required this.child, required this.sensitive, this.safeArea = true});
309303

310304
@override
311305
Widget build(BuildContext context) {
@@ -346,18 +340,48 @@ class _Panel extends StatelessWidget {
346340
? sensitiveColor.withValues(alpha: 0.3)
347341
: colorScheme.secondaryContainer.withValues(alpha: 0.3);
348342

343+
final content = Padding(
344+
padding: const EdgeInsets.all(4.0),
345+
child: child,
346+
);
347+
349348
return ColoredBox(
350349
color: colorScheme.surface,
351350
child: Theme(
352351
data: localThemeData,
353352
child: ColoredBox(
354353
color: panelBackgroundColor,
355-
child: Padding(
356-
padding: const EdgeInsets.all(4.0),
357-
child: child,
358-
),
354+
child: safeArea ? SafeArea(child: content) : content,
359355
),
360356
),
361357
);
362358
}
363359
}
360+
361+
class PanelList extends ConsumerWidget {
362+
const PanelList({super.key});
363+
364+
@override
365+
Widget build(BuildContext context, WidgetRef ref) {
366+
final logPanelVisible = ref.watch(logPanelVisibilityProvider);
367+
final allowScreenshots =
368+
isAndroid ? ref.watch(androidAllowScreenshotsProvider) : false;
369+
return Column(
370+
mainAxisSize: MainAxisSize.min,
371+
crossAxisAlignment: CrossAxisAlignment.stretch,
372+
children: [
373+
if (allowScreenshots)
374+
Flexible(
375+
child: _WarningPanel(
376+
safeArea: !logPanelVisible,
377+
),
378+
),
379+
if (allowScreenshots && logPanelVisible) const SizedBox(height: 4.0),
380+
if (logPanelVisible)
381+
Flexible(
382+
child: _LoggingPanel(safeArea: true),
383+
)
384+
],
385+
);
386+
}
387+
}

lib/app/views/app_page.dart

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -755,17 +755,8 @@ class _AppPageState extends ConsumerState<AppPage> {
755755
],
756756
),
757757
),
758-
bottomNavigationBar: SafeArea(
759-
child: Column(
760-
key: loggingPanelKey,
761-
mainAxisSize: MainAxisSize.min,
762-
crossAxisAlignment: CrossAxisAlignment.stretch,
763-
spacing: 4.0,
764-
children: [
765-
Flexible(child: WarningPanel()),
766-
Flexible(child: LoggingPanel()),
767-
],
768-
),
758+
bottomNavigationBar: PanelList(
759+
key: loggingPanelKey,
769760
),
770761
drawer: hasDrawer ? _buildDrawer(context) : null,
771762
body: body,

lib/widgets/toast.dart

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,28 +129,32 @@ void Function() showToast(
129129
loggingPanelKey.currentContext?.findRenderObject() as RenderBox?;
130130
final panelHeight = panelBox?.size.height ?? 0.0;
131131

132+
final content = Align(
133+
alignment: Alignment.bottomCenter,
134+
child: Container(
135+
height: 50,
136+
width: 400,
137+
margin: const EdgeInsets.all(8),
138+
child: Toast(
139+
message,
140+
duration,
141+
backgroundColor: backgroundColor,
142+
textStyle: textStyle,
143+
onComplete: close,
144+
),
145+
),
146+
);
147+
132148
entry = OverlayEntry(builder: (context) {
133149
return Positioned(
134150
bottom: MediaQuery.of(context).viewInsets.bottom + panelHeight,
135151
left: 0,
136152
right: 0,
137-
child: SafeArea(
138-
child: Align(
139-
alignment: Alignment.bottomCenter,
140-
child: Container(
141-
height: 50,
142-
width: 400,
143-
margin: const EdgeInsets.all(8),
144-
child: Toast(
145-
message,
146-
duration,
147-
backgroundColor: backgroundColor,
148-
textStyle: textStyle,
149-
onComplete: close,
153+
child: panelHeight > 0
154+
? content // Panel already adds SafeArea
155+
: SafeArea(
156+
child: content,
150157
),
151-
),
152-
),
153-
),
154158
);
155159
});
156160
Timer.run(() {

0 commit comments

Comments
 (0)