Skip to content

Commit

Permalink
fix(fissures): give Omnia fissures a glitch effect
Browse files Browse the repository at this point in the history
  • Loading branch information
SlayerOrnstein committed Mar 31, 2024
1 parent 097a3bc commit 756d6df
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 16 deletions.
66 changes: 59 additions & 7 deletions lib/worldstate/widgets/fissures/fissure_widget.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'dart:async';
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:navis/l10n/l10n.dart';
import 'package:navis_ui/navis_ui.dart';
Expand Down Expand Up @@ -30,22 +33,23 @@ class FissureWidget extends StatelessWidget {
const opacity = .30;

final icon = () {
switch (fissure.tier) {
case 'Lith':
switch (fissure.tierNum) {
case 1:
return WarframeSymbols.fissures_lith;
case 'Meso':
case 2:
return WarframeSymbols.fissures_meso;
case 'Neo':
case 3:
return WarframeSymbols.fissures_neo;
case 'Axi':
case 4:
return WarframeSymbols.fissures_axi;
default:
case 5:
return WarframeSymbols.fissures_requiem;
}
}();

return SkyboxCard(
node: fissure.node,
enableGlitch: fissure.tierNum == 6,
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 16),
child: Stack(
children: [
Expand All @@ -67,7 +71,9 @@ class FissureWidget extends StatelessWidget {
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Icon(icon, size: 40),
child: fissure.tierNum == 6
? const OmniaFissureWidget()
: Icon(icon, size: 40),
),
Expanded(
child: _FissureInfo(
Expand Down Expand Up @@ -121,3 +127,49 @@ class _FissureInfo extends StatelessWidget {
);
}
}

class OmniaFissureWidget extends StatefulWidget {
const OmniaFissureWidget({super.key});

@override
State<OmniaFissureWidget> createState() => _OmniaFissureWidgetState();
}

class _OmniaFissureWidgetState extends State<OmniaFissureWidget> {
static const _icons = [
WarframeSymbols.fissures_lith,
WarframeSymbols.fissures_meso,
WarframeSymbols.fissures_neo,
WarframeSymbols.fissures_axi,
WarframeSymbols.fissures_requiem,
];

late final Timer timer;
late final Random rand;

@override
void initState() {
super.initState();

rand = Random();
timer = Timer.periodic(const Duration(seconds: 5), (timer) {
if (mounted) setState(() {});
});
}

@override
Widget build(BuildContext context) {
return AnimatedSwitcher(
duration: const Duration(milliseconds: 1500),
switchInCurve: Curves.easeInOut,
switchOutCurve: Curves.easeInOut,
child: Icon(_icons[rand.nextInt(5)], size: 40),
);
}

@override
void dispose() {
timer.cancel();
super.dispose();
}
}
32 changes: 23 additions & 9 deletions packages/navis_ui/lib/src/widgets/skybox_card.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:animated_glitch/animated_glitch.dart';
import 'package:flutter/material.dart';
import 'package:navis_ui/navis_ui.dart';

Expand All @@ -8,30 +9,43 @@ class SkyboxCard extends StatelessWidget {
this.margin = const EdgeInsets.symmetric(vertical: 3, horizontal: 3),
this.padding = const EdgeInsets.symmetric(vertical: 3, horizontal: 3),
this.height = 100,
this.enableGlitch = false,
required this.child,
}) : super(key: key);

final String node;

final EdgeInsetsGeometry margin, padding;
final double height;
final bool enableGlitch;
final Widget child;

@override
Widget build(BuildContext context) {
Widget child = BackgroundImage(
imageUrl: getSkybox(node),
padding: padding,
child: this.child,
);

if (enableGlitch) {
child = AnimatedGlitch.shader(
glitchAmount: 1,
distortionLevel: 2,
showColorChannels: false,
child: SizedBox(
height: double.infinity,
width: double.infinity,
child: child,
),
);
}

return Theme(
data: NavisThemes.dark,
child: Card(
clipBehavior: Clip.antiAlias,
margin: margin,
child: SizedBox(
height: height,
child: BackgroundImage(
imageUrl: getSkybox(node),
padding: padding,
child: child,
),
),
child: child,
),
);
}
Expand Down
8 changes: 8 additions & 0 deletions packages/navis_ui/pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
animated_glitch:
dependency: "direct main"
description:
name: animated_glitch
sha256: "0e9dac2a8863f3a77861192d9f136062d1776e50a63ab8d2325f331bd2cd3f63"
url: "https://pub.dev"
source: hosted
version: "2.0.0+2"
async:
dependency: transitive
description:
Expand Down
3 changes: 3 additions & 0 deletions packages/navis_ui/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ environment:
sdk: ">=3.2.0 <4.0.0"

dependencies:
animated_glitch: ^2.0.0+2
black_hole_flutter: ^1.0.1
cached_network_image: ^3.3.0
flutter:
Expand All @@ -27,6 +28,8 @@ flutter:
- asset: lib/fonts/Warframe-symbols.ttf
assets:
- assets/Derelict.webp
shaders:
- 'packages/animated_glitch/shader/glitch.frag'

flutter_gen:
assets:
Expand Down
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.4.1"
animated_glitch:
dependency: transitive
description:
name: animated_glitch
sha256: "0e9dac2a8863f3a77861192d9f136062d1776e50a63ab8d2325f331bd2cd3f63"
url: "https://pub.dev"
source: hosted
version: "2.0.0+2"
animations:
dependency: "direct main"
description:
Expand Down

0 comments on commit 756d6df

Please sign in to comment.