From e2e2c544242754415bde8437f68ca04156a6b8f2 Mon Sep 17 00:00:00 2001 From: PaulGD03 Date: Tue, 7 Jan 2025 16:30:43 +0100 Subject: [PATCH] fix(settings, util): undo removal of self-destruct easter egg - will be replaced by a new easter egg in the future. --- lib/settings/general_screen.dart | 57 ++++++++++++++++++++++++++++++++ lib/util/orion_config.dart | 50 ++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) diff --git a/lib/settings/general_screen.dart b/lib/settings/general_screen.dart index 3fa47d5..2f4b784 100644 --- a/lib/settings/general_screen.dart +++ b/lib/settings/general_screen.dart @@ -48,6 +48,7 @@ class GeneralCfgScreenState extends State { late bool overrideUpdateCheck; late String overrideRelease; late bool verboseLogging; + late bool selfDestructMode; late String machineName; late String originalRotation; @@ -80,12 +81,25 @@ class GeneralCfgScreenState extends State { overrideRelease = config.getString('overrideRelease', category: 'developer'); verboseLogging = config.getFlag('verboseLogging', category: 'developer'); + selfDestructMode = + config.getFlag('selfDestructMode', category: 'topsecret'); screenRotation = screenRotation == '' ? '0' : screenRotation; config.setString('screenRotation', screenRotation, category: 'advanced'); originalRotation = screenRotation; machineName = config.getString('machineName', category: 'machine'); } + bool shouldDestruct() { + final rand = Random(); + if (selfDestructMode && rand.nextInt(1000) < 2) { + setState(() { + selfDestructMode = false; + }); + return true; + } + return !selfDestructMode; + } + bool isJune() { final now = DateTime.now(); return now.month == 6; @@ -123,6 +137,49 @@ class GeneralCfgScreenState extends State { ), ), ), + if (shouldDestruct()) + Card( + elevation: 1, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular( + 10), // match this with your Card's border radius + gradient: LinearGradient( + colors: [ + Colors.red, + Colors.orange, + Colors.yellow, + Colors.green, + Colors.blue, + Colors.indigo, + Colors.purple + ] + .map((color) => + Color.lerp(color, Colors.black, 0.25)) + .where((color) => color != null) + .cast() + .toList(), + ), + ), + child: Padding( + padding: const EdgeInsets.all(16), + child: OrionListTile( + ignoreColor: true, + title: 'Self-Destruct Mode', + icon: PhosphorIcons.skull, + value: selfDestructMode, + onChanged: (bool value) { + setState(() { + selfDestructMode = value; + config.setFlag('selfDestructMode', selfDestructMode, + category: 'topsecret'); + config.blowUp(context, 'assets/images/bsod.png'); + }); + }, + ), + ), + ), + ), Card.outlined( elevation: 1, child: Padding( diff --git a/lib/util/orion_config.dart b/lib/util/orion_config.dart index 1b4ba44..d90ac5e 100644 --- a/lib/util/orion_config.dart +++ b/lib/util/orion_config.dart @@ -155,6 +155,56 @@ class OrionConfig { configFile.writeAsStringSync(encoder.convert(configToWrite)); } + void blowUp(BuildContext context, String imagePath) { + _logger.severe('Blowing up the app'); + showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return FutureBuilder( + future: Future.delayed(const Duration(seconds: 4)), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return SafeArea( + child: Dialog( + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.zero), + insetPadding: EdgeInsets.zero, + backgroundColor: Theme.of(context).colorScheme.surface, + child: const Center( + child: SizedBox( + height: 75, + width: 75, + child: CircularProgressIndicator( + strokeWidth: 6, + ), + ), + ), + ), + ); + } else { + Future.delayed(const Duration(seconds: 10), () { + Navigator.of(context).pop(true); + }); + return SafeArea( + child: Dialog( + insetPadding: EdgeInsets.zero, + backgroundColor: Colors.transparent, + child: Image.asset( + imagePath, + fit: BoxFit.fill, + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height, + ), + ), + ); + } + }, + ); + }, + ); + } + Map _mergeConfigs( Map base, Map overlay) { var result = Map.from(base);