From 9f0342ba1a0a67ea597ad3e426e567012dbd7d36 Mon Sep 17 00:00:00 2001 From: Bearmine Date: Fri, 20 Feb 2026 19:28:38 -0600 Subject: [PATCH] Setup blank app layout --- adventofcode2025/lib/days_enum.dart | 12 ++ adventofcode2025/lib/main.dart | 195 +++++++++++++++------------- adventofcode2025/pubspec.lock | 24 ++++ adventofcode2025/pubspec.yaml | 2 + 4 files changed, 141 insertions(+), 92 deletions(-) create mode 100644 adventofcode2025/lib/days_enum.dart diff --git a/adventofcode2025/lib/days_enum.dart b/adventofcode2025/lib/days_enum.dart new file mode 100644 index 0000000..e19409e --- /dev/null +++ b/adventofcode2025/lib/days_enum.dart @@ -0,0 +1,12 @@ + + +enum AdventOfCodeDays { + day1(title: "Day 1"), + day2(title: "Day 2"),; + + const AdventOfCodeDays({ + required this.title + }); + + final String title; +} \ No newline at end of file diff --git a/adventofcode2025/lib/main.dart b/adventofcode2025/lib/main.dart index 244a702..503e2f3 100644 --- a/adventofcode2025/lib/main.dart +++ b/adventofcode2025/lib/main.dart @@ -1,122 +1,133 @@ +// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables + +import 'package:english_words/english_words.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'days_enum.dart'; void main() { - runApp(const MyApp()); + runApp(MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); - // This widget is the root of your application. @override Widget build(BuildContext context) { - return MaterialApp( - title: 'Flutter Demo', - theme: ThemeData( - // This is the theme of your application. - // - // TRY THIS: Try running your application with "flutter run". You'll see - // the application has a purple toolbar. Then, without quitting the app, - // try changing the seedColor in the colorScheme below to Colors.green - // and then invoke "hot reload" (save your changes or press the "hot - // reload" button in a Flutter-supported IDE, or press "r" if you used - // the command line to start the app). - // - // Notice that the counter didn't reset back to zero; the application - // state is not lost during the reload. To reset the state, use hot - // restart instead. - // - // This works for code too, not just values: Most code changes can be - // tested with just a hot reload. - colorScheme: .fromSeed(seedColor: Colors.deepPurple), + return ChangeNotifierProvider( + create: (context) => MyAppState(), + child: MaterialApp( + title: 'Advent of Code 2025', + theme: ThemeData( + useMaterial3: true, + colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepOrange), + ), + home: MyHomePage(), ), - home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } +class MyAppState extends ChangeNotifier { + var current = WordPair.random(); + var history = []; + + GlobalKey? historyListKey; + + void getNext() { + history.insert(0, current); + var animatedList = historyListKey?.currentState as AnimatedListState?; + animatedList?.insertItem(0); + current = WordPair.random(); + notifyListeners(); + } + + var favorites = []; + + void toggleFavorite([WordPair? pair]) { + pair = pair ?? current; + if (favorites.contains(pair)) { + favorites.remove(pair); + } else { + favorites.add(pair); + } + notifyListeners(); + } + + void removeFavorite(WordPair pair) { + favorites.remove(pair); + notifyListeners(); + } +} + class MyHomePage extends StatefulWidget { - const MyHomePage({super.key, required this.title}); - - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". - - final String title; - @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; - }); - } + var selectedIndex = 0; @override Widget build(BuildContext context) { - // This method is rerun every time setState is called, for instance as done - // by the _incrementCounter method above. - // - // The Flutter framework has been optimized to make rerunning build methods - // fast, so that you can just rebuild anything that needs updating rather - // than having to individually change instances of widgets. - return Scaffold( - appBar: AppBar( - // TRY THIS: Try changing the color here to a specific color (to - // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar - // change color while the other colors stay the same. - backgroundColor: Theme.of(context).colorScheme.inversePrimary, - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. - title: Text(widget.title), - ), - body: Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. - child: Column( - // Column is also a layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). - // - // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint" - // action in the IDE, or press "p" in the console), to see the - // wireframe for each widget. - mainAxisAlignment: .center, - children: [ - const Text('You have pushed the button this many times:'), - Text( - '$_counter', - style: Theme.of(context).textTheme.headlineMedium, - ), - ], + // Manage days and create items list of a pages. + final days = [AdventOfCodeDays.day1, AdventOfCodeDays.day2]; + List dayItems = []; + for (var day in days) { + dayItems.add( + NavigationRailDestination( + icon: Icon(Icons.arrow_forward_ios), + label: Text(day.title), ), + ); + } + var colorScheme = Theme.of(context).colorScheme; + + Widget page = DayPage(); + + // The container for the current page, with its background color + // and subtle switching animation. + var mainArea = ColoredBox( + color: colorScheme.surfaceContainerHighest, + child: AnimatedSwitcher( + duration: Duration(milliseconds: 200), + child: page, ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), + ); + + return Scaffold( + body: LayoutBuilder( + builder: (context, constraints) { + return Row( + children: [ + SafeArea( + child: NavigationRail( + extended: constraints.maxWidth >= 600, + destinations: dayItems, + selectedIndex: selectedIndex, + onDestinationSelected: (value) { + setState(() { + selectedIndex = value; + }); + }, + ), + ), + Expanded(child: mainArea), + ], + ); + }, ), ); } } + +class DayPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Column( + children: [ + Row(children: [SizedBox(width: 10)]), + ], + ); + } +} diff --git a/adventofcode2025/pubspec.lock b/adventofcode2025/pubspec.lock index 08f88ae..2fa07ee 100644 --- a/adventofcode2025/pubspec.lock +++ b/adventofcode2025/pubspec.lock @@ -49,6 +49,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.8" + english_words: + dependency: "direct main" + description: + name: english_words + sha256: "6a7ef6473a97bd8571b6b641d006a6e58a7c67e65fb6f3d6d1151cb46b0e983c" + url: "https://pub.dev" + source: hosted + version: "4.0.0" fake_async: dependency: transitive description: @@ -131,6 +139,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.0" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" + source: hosted + version: "1.0.0" path: dependency: transitive description: @@ -139,6 +155,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" + provider: + dependency: "direct main" + description: + name: provider + sha256: "4e82183fa20e5ca25703ead7e05de9e4cceed1fbd1eadc1ac3cb6f565a09f272" + url: "https://pub.dev" + source: hosted + version: "6.1.5+1" sky_engine: dependency: transitive description: flutter diff --git a/adventofcode2025/pubspec.yaml b/adventofcode2025/pubspec.yaml index cc13273..a642710 100644 --- a/adventofcode2025/pubspec.yaml +++ b/adventofcode2025/pubspec.yaml @@ -34,6 +34,8 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.8 + english_words: ^4.0.0 + provider: ^6.1.5+1 dev_dependencies: flutter_test: