Move flutter app into root of repo
This commit is contained in:
103
lib/main.dart
Normal file
103
lib/main.dart
Normal file
@@ -0,0 +1,103 @@
|
||||
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'days_enum.dart';
|
||||
|
||||
void main() {
|
||||
runApp(MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChangeNotifierProvider(
|
||||
create: (context) => MyAppState(),
|
||||
child: MaterialApp(
|
||||
title: 'Advent of Code 2025',
|
||||
theme: ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepOrange),
|
||||
),
|
||||
home: MyHomePage(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyAppState extends ChangeNotifier {
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
@override
|
||||
State<MyHomePage> createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
var selectedIndex = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 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),
|
||||
),
|
||||
);
|
||||
}
|
||||
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,
|
||||
),
|
||||
);
|
||||
|
||||
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)]),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user