desktop_flow 0.0.2 desktop_flow: ^0.0.2 copied to clipboard
A flutter package to help you create desktop apps.
import 'dart:developer';
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:desktop_flow/desktop_flow.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
doWhenWindowReady(() {
const size = Size(800, 650);
appWindow.size = size;
appWindow.minSize = size;
appWindow.alignment = Alignment.center;
appWindow.show();
});
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
final _controller = DesktopController(
menuIndex: 0,
screen: const RedScreen(),
isActionsVisible: false,
);
return MaterialApp(
debugShowCheckedModeBanner: false,
home: DesktopFlow(
controller: _controller,
lateralMenuItems: [
MenuItem(
index: 0,
icon: const Icon(Icons.home),
tooltip: "Inicio",
backgroundColor: Colors.orange.shade300,
onTap: () => log("message"),
jumpTo: RedScreen(onPressed: () => _controller.showActionButtons()),
),
MenuItem(
index: 1,
icon: const Icon(Icons.favorite),
tooltip: "Favoritos",
backgroundColor: Colors.orange.shade300,
jumpTo: const BlueScreen(),
),
MenuItem(
index: 2,
icon: const Icon(Icons.settings),
tooltip: "Configurações",
backgroundColor: Colors.orange.shade300,
)
],
),
);
}
}
class RedScreen extends StatelessWidget {
const RedScreen({
Key? key,
this.onPressed,
}) : super(key: key);
final VoidCallback? onPressed;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: DesktopAppBar(
title: "Tela vermelha",
actionButtons: [
ActionButton(
icon: const Icon(Icons.save),
tooltip: "Salvar",
onTap: () {},
backgroundColor: Colors.green.shade100,
)
],
),
body: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
color: Colors.red,
child: Center(
child: TextButton(
onPressed: onPressed,
child: const Text("mostrar ações"),
)),
),
);
}
}
class BlueScreen extends StatelessWidget {
const BlueScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: DesktopAppBar(
title: "Tela azul",
backgroundColor: Colors.black54,
windowButtons: [
MinimizeWindowButton(),
CloseWindowButton(),
],
actionButtons: const [],
),
body: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
color: Colors.blue,
child: Center(),
),
);
}
}