|
| 1 | +import 'package:algorithm_visualizer/core/resources/color_manager.dart'; |
| 2 | +import 'package:flutter/material.dart'; |
| 3 | +import 'package:flutter/services.dart'; |
| 4 | + |
| 5 | +class SystemOverlay extends StatelessWidget { |
| 6 | + const SystemOverlay({ |
| 7 | + required this.child, |
| 8 | + this.isBlackTheme = true, |
| 9 | + super.key, |
| 10 | + }); |
| 11 | + final Widget child; |
| 12 | + final bool isBlackTheme; |
| 13 | + @override |
| 14 | + Widget build(BuildContext context) { |
| 15 | + return AnnotatedRegion<SystemUiOverlayStyle>( |
| 16 | + value: isBlackTheme ? blackTheme() : whiteTheme(), |
| 17 | + child: child, |
| 18 | + ); |
| 19 | + } |
| 20 | + |
| 21 | + SystemUiOverlayStyle blackTheme() { |
| 22 | + return const SystemUiOverlayStyle( |
| 23 | + statusBarColor: ColorManager.black, |
| 24 | + statusBarIconBrightness: Brightness.light, |
| 25 | + systemNavigationBarColor: ColorManager.blackL2, |
| 26 | + systemNavigationBarIconBrightness: Brightness.light); |
| 27 | + } |
| 28 | + |
| 29 | + SystemUiOverlayStyle whiteTheme() { |
| 30 | + return const SystemUiOverlayStyle( |
| 31 | + statusBarColor: ColorManager.white, |
| 32 | + statusBarIconBrightness: Brightness.dark, |
| 33 | + systemNavigationBarColor: ColorManager.white, |
| 34 | + systemNavigationBarIconBrightness: Brightness.dark); |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +class TransparentSystemOverlay extends StatelessWidget { |
| 39 | + const TransparentSystemOverlay({required this.child, super.key}); |
| 40 | + final Widget child; |
| 41 | + @override |
| 42 | + Widget build(BuildContext context) { |
| 43 | + return AnnotatedRegion<SystemUiOverlayStyle>( |
| 44 | + value: transparentTheme(), |
| 45 | + child: child, |
| 46 | + ); |
| 47 | + } |
| 48 | + |
| 49 | + SystemUiOverlayStyle transparentTheme() { |
| 50 | + return const SystemUiOverlayStyle( |
| 51 | + statusBarColor: Colors.transparent, |
| 52 | + systemNavigationBarColor: Colors.transparent, |
| 53 | + systemNavigationBarDividerColor: ColorManager.transparent |
| 54 | + ); |
| 55 | + } |
| 56 | +} |
0 commit comments