main skeleton of app
This commit is contained in:
commit
24f458b06f
36 changed files with 1783 additions and 0 deletions
35
lib/app.dart
Normal file
35
lib/app.dart
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:system_theme/system_theme.dart';
|
||||
|
||||
import 'pages.dart';
|
||||
|
||||
class LadleApp extends StatelessWidget {
|
||||
const LadleApp({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FluentApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'Ladle',
|
||||
theme: ThemeData.light()
|
||||
..copyWith(
|
||||
accentColor: SystemTheme.accentColor.accent.toAccentColor(),
|
||||
),
|
||||
darkTheme: ThemeData.dark()
|
||||
..copyWith(
|
||||
accentColor: SystemTheme.accentColor.accent.toAccentColor(),
|
||||
),
|
||||
onGenerateRoute: _generateRoutes,
|
||||
);
|
||||
}
|
||||
|
||||
Route? _generateRoutes(RouteSettings settings) {
|
||||
if (settings.name == '/') {
|
||||
return FluentPageRoute(
|
||||
builder: (context) => const HomePage(),
|
||||
);
|
||||
}
|
||||
|
||||
throw Exception('Invalid route: ${settings.name}');
|
||||
}
|
||||
}
|
||||
11
lib/bloc/scoop_list_bloc.dart
Normal file
11
lib/bloc/scoop_list_bloc.dart
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import 'package:bloc/bloc.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
part 'scoop_list_event.dart';
|
||||
part 'scoop_list_state.dart';
|
||||
|
||||
class ScoopListBloc extends Bloc<ScoopListEvent, ScoopListState> {
|
||||
ScoopListBloc() : super(ScoopListInitial()) {
|
||||
on<ScoopListEvent>((event, emit) {});
|
||||
}
|
||||
}
|
||||
4
lib/bloc/scoop_list_event.dart
Normal file
4
lib/bloc/scoop_list_event.dart
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
part of 'scoop_list_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ScoopListEvent {}
|
||||
6
lib/bloc/scoop_list_state.dart
Normal file
6
lib/bloc/scoop_list_state.dart
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
part of 'scoop_list_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ScoopListState {}
|
||||
|
||||
class ScoopListInitial extends ScoopListState {}
|
||||
32
lib/main.dart
Normal file
32
lib/main.dart
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import 'package:bitsdojo_window/bitsdojo_window.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:ladle/bloc/scoop_list_bloc.dart';
|
||||
import 'package:system_theme/system_theme.dart';
|
||||
|
||||
import 'app.dart';
|
||||
|
||||
void main() async {
|
||||
final binding =
|
||||
WidgetsFlutterBinding.ensureInitialized() as WidgetsFlutterBinding;
|
||||
|
||||
await SystemTheme.accentColor.load();
|
||||
|
||||
doWhenWindowReady(() {
|
||||
const initialSize = Size(600, 450);
|
||||
appWindow.minSize = initialSize;
|
||||
appWindow.size = initialSize;
|
||||
appWindow.alignment = Alignment.center;
|
||||
appWindow.title = 'Ladle';
|
||||
appWindow.show();
|
||||
});
|
||||
|
||||
runApp(MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider(
|
||||
create: (context) => ScoopListBloc(),
|
||||
),
|
||||
],
|
||||
child: const LadleApp(),
|
||||
));
|
||||
}
|
||||
1
lib/pages.dart
Normal file
1
lib/pages.dart
Normal file
|
|
@ -0,0 +1 @@
|
|||
export 'pages/home_page.dart';
|
||||
39
lib/pages/app_list_fragment.dart
Normal file
39
lib/pages/app_list_fragment.dart
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
|
||||
class AppListFragment extends StatefulWidget {
|
||||
const AppListFragment({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AppListFragment> createState() => _AppListFragmentState();
|
||||
}
|
||||
|
||||
class _AppListFragmentState extends State<AppListFragment> {
|
||||
int currentIndex = 0;
|
||||
int tabs = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 600,
|
||||
child: TabView(
|
||||
currentIndex: currentIndex,
|
||||
onChanged: (index) => setState(() => currentIndex = index),
|
||||
onNewPressed: () {
|
||||
setState(() => tabs++);
|
||||
},
|
||||
tabs: List.generate(tabs, (index) {
|
||||
return Tab(
|
||||
text: Text('Tab $index'),
|
||||
closeIcon: FluentIcons.chrome_close,
|
||||
);
|
||||
}),
|
||||
bodies: List.generate(
|
||||
tabs,
|
||||
(index) => Container(
|
||||
color: index.isEven ? Colors.red : Colors.yellow,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
74
lib/pages/home_page.dart
Normal file
74
lib/pages/home_page.dart
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import 'package:bitsdojo_window/bitsdojo_window.dart';
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
|
||||
import '../widgets/windows_buttons_widget.dart';
|
||||
import 'app_list_fragment.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<HomePage> createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
int _fragmentIndex = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return NavigationView(
|
||||
appBar: _buildAppbar(),
|
||||
pane: _buildNavigationPane(),
|
||||
content: _buildContent(),
|
||||
);
|
||||
}
|
||||
|
||||
NavigationAppBar _buildAppbar() {
|
||||
return NavigationAppBar(
|
||||
title: MoveWindow(
|
||||
child: const Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text("Ladle"),
|
||||
),
|
||||
),
|
||||
actions: MoveWindow(
|
||||
child: Row(children: const [Spacer(), WindowButtons()]),
|
||||
),
|
||||
automaticallyImplyLeading: false,
|
||||
);
|
||||
}
|
||||
|
||||
NavigationPane _buildNavigationPane() {
|
||||
return NavigationPane(
|
||||
selected: _fragmentIndex,
|
||||
displayMode: PaneDisplayMode.top,
|
||||
onChanged: (i) => setState(() => _fragmentIndex = i),
|
||||
items: [
|
||||
PaneItem(
|
||||
title: const Text("Home"),
|
||||
icon: const Icon(FluentIcons.home),
|
||||
),
|
||||
PaneItem(
|
||||
title: const Text("Updates"),
|
||||
icon: const Icon(FluentIcons.update_restore),
|
||||
),
|
||||
PaneItemSeparator(),
|
||||
PaneItem(
|
||||
title: const Text("Settings"),
|
||||
icon: const Icon(FluentIcons.settings),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
NavigationBody _buildContent() {
|
||||
return NavigationBody(
|
||||
index: _fragmentIndex,
|
||||
children: const [
|
||||
AppListFragment(),
|
||||
Center(child: Text("Scoops")),
|
||||
Center(child: Text("Settings")),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
24
lib/widgets/windows_buttons_widget.dart
Normal file
24
lib/widgets/windows_buttons_widget.dart
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import 'package:bitsdojo_window/bitsdojo_window.dart';
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
|
||||
class WindowButtons extends StatelessWidget {
|
||||
const WindowButtons({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = FluentTheme.of(context);
|
||||
|
||||
return SizedBox(
|
||||
width: 138,
|
||||
height: 50,
|
||||
// ? For some reasong {WindowsCaption} is not available
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
MinimizeWindowButton(),
|
||||
CloseWindowButton(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue