2026-02-20 19:28:38 -06:00
|
|
|
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables
|
|
|
|
|
|
2026-02-17 22:02:18 -06:00
|
|
|
import 'package:flutter/material.dart';
|
2026-02-20 19:28:38 -06:00
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'days_enum.dart';
|
2026-02-21 15:56:39 -06:00
|
|
|
import 'day_page.dart';
|
2026-03-17 16:14:41 -05:00
|
|
|
import "util.dart";
|
2026-02-17 22:02:18 -06:00
|
|
|
|
|
|
|
|
void main() {
|
2026-02-20 19:28:38 -06:00
|
|
|
runApp(MyApp());
|
2026-02-17 22:02:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-02-20 19:28:38 -06:00
|
|
|
return ChangeNotifierProvider(
|
|
|
|
|
create: (context) => MyAppState(),
|
|
|
|
|
child: MaterialApp(
|
|
|
|
|
title: 'Advent of Code 2025',
|
|
|
|
|
theme: ThemeData(
|
|
|
|
|
useMaterial3: true,
|
|
|
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepOrange),
|
|
|
|
|
),
|
|
|
|
|
home: MyHomePage(),
|
2026-02-17 22:02:18 -06:00
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-17 16:14:41 -05:00
|
|
|
class DayPageState {
|
|
|
|
|
String? selectedFile;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-20 19:28:38 -06:00
|
|
|
class MyAppState extends ChangeNotifier {
|
2026-03-17 16:14:41 -05:00
|
|
|
Map<AdventOfCodeDays, DayPageState> dayPageState = {};
|
|
|
|
|
|
|
|
|
|
MyAppState() {
|
|
|
|
|
for (var day in AdventOfCodeDays.values) {
|
|
|
|
|
dayPageState[day] = DayPageState();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String? getSelectedFile(AdventOfCodeDays day) {
|
|
|
|
|
return dayPageState[day]?.selectedFile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setSelectedFile(AdventOfCodeDays day, String? file) {
|
|
|
|
|
debugLog("setSelectedFile called on $day");
|
|
|
|
|
dayPageState[day]?.selectedFile = file;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
2026-02-20 19:28:38 -06:00
|
|
|
}
|
2026-02-17 22:02:18 -06:00
|
|
|
|
2026-02-20 19:28:38 -06:00
|
|
|
class MyHomePage extends StatefulWidget {
|
2026-02-21 15:56:39 -06:00
|
|
|
const MyHomePage({super.key});
|
|
|
|
|
|
2026-02-17 22:02:18 -06:00
|
|
|
@override
|
|
|
|
|
State<MyHomePage> createState() => _MyHomePageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
2026-02-20 19:28:38 -06:00
|
|
|
var selectedIndex = 0;
|
2026-02-17 22:02:18 -06:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-02-20 19:28:38 -06:00
|
|
|
// Manage days and create items list of a pages.
|
|
|
|
|
final days = [AdventOfCodeDays.day1, AdventOfCodeDays.day2];
|
|
|
|
|
List<NavigationRailDestination> dayItems = [];
|
|
|
|
|
for (var day in days) {
|
|
|
|
|
dayItems.add(
|
|
|
|
|
NavigationRailDestination(
|
|
|
|
|
icon: Icon(Icons.arrow_forward_ios),
|
|
|
|
|
label: Text(day.title),
|
2026-02-17 22:02:18 -06:00
|
|
|
),
|
2026-02-20 19:28:38 -06:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
var colorScheme = Theme.of(context).colorScheme;
|
|
|
|
|
|
2026-03-17 16:14:41 -05:00
|
|
|
Widget page = DayPage(AdventOfCodeDays.day1);
|
2026-02-20 19:28:38 -06:00
|
|
|
|
|
|
|
|
// 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,
|
2026-02-17 22:02:18 -06:00
|
|
|
),
|
2026-02-20 19:28:38 -06:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
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),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
2026-02-17 22:02:18 -06:00
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|