diff options
| author | Orangerot <purple@orangerot.dev> | 2024-12-29 16:25:32 +0100 | 
|---|---|---|
| committer | Orangerot <purple@orangerot.dev> | 2024-12-29 16:25:32 +0100 | 
| commit | 5a763a5de26981c7d015a9e6276017b0f6c12f67 (patch) | |
| tree | 5bfabf44be006101add9473c39a6ea13cc133ad2 /lib/arrows.dart | |
| parent | e9ba842e21503c00686e468729ad1f57ae96241b (diff) | |
style: refactored arrows in own file
Diffstat (limited to 'lib/arrows.dart')
| -rw-r--r-- | lib/arrows.dart | 57 | 
1 files changed, 57 insertions, 0 deletions
diff --git a/lib/arrows.dart b/lib/arrows.dart new file mode 100644 index 0000000..b4779f7 --- /dev/null +++ b/lib/arrows.dart @@ -0,0 +1,57 @@ +import 'package:flutter/material.dart'; + +enum ArrowDirection { +  left(Icons.arrow_back), +  down(Icons.arrow_downward), +  up(Icons.arrow_upward), +  right(Icons.arrow_forward); + +  const ArrowDirection(this.icon); + +  final IconData icon; +} + +class Note { +  final double time; +  final ArrowDirection direction; +  double position = 0; +  bool wasHit = false; + +  Note({required this.time, required this.direction}); +} + +class Arrows extends StatelessWidget { +  final List<Note> notes; +  final double position; + +  const Arrows({super.key, required this.notes, required this.position}); + +  @override +  Widget build(BuildContext context) { +    return Stack( +        children: notes.map((note) { +      double position = note.position * 10000; //  * 20 * MediaQuery.of(context).size.height; + +      return Arrow( +        position: position, +        direction: note.direction, +      ); +    }).toList()); +  } +} + +class Arrow extends StatelessWidget { +  final double position; +  final ArrowDirection direction; + +  const Arrow({super.key, required this.position, required this.direction}); + +  @override +  Widget build(BuildContext context) { +    return Positioned( +      left: MediaQuery.of(context).size.width / 2 - 50, // Center the arrow +      bottom: position + 50, +      child: Icon(size: 100, color: Colors.redAccent.shade400, direction.icon), +    ); +  } +}  | 
