Skip to content

Commit

Permalink
fix(settings, util): undo removal of self-destruct easter egg
Browse files Browse the repository at this point in the history
- will be replaced by a new easter egg in the future.
  • Loading branch information
PaulGD03 committed Jan 7, 2025
1 parent a00cd36 commit e2e2c54
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
57 changes: 57 additions & 0 deletions lib/settings/general_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class GeneralCfgScreenState extends State<GeneralCfgScreen> {
late bool overrideUpdateCheck;
late String overrideRelease;
late bool verboseLogging;
late bool selfDestructMode;
late String machineName;

late String originalRotation;
Expand Down Expand Up @@ -80,12 +81,25 @@ class GeneralCfgScreenState extends State<GeneralCfgScreen> {
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;
Expand Down Expand Up @@ -123,6 +137,49 @@ class GeneralCfgScreenState extends State<GeneralCfgScreen> {
),
),
),
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<Color>()
.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(
Expand Down
50 changes: 50 additions & 0 deletions lib/util/orion_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, dynamic> _mergeConfigs(
Map<String, dynamic> base, Map<String, dynamic> overlay) {
var result = Map<String, dynamic>.from(base);
Expand Down

0 comments on commit e2e2c54

Please sign in to comment.