diff --git a/lib/main.dart b/lib/main.dart index 7ebe820..2db4f6c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -9,17 +9,6 @@ import 'package:quickgui/src/model/version.dart'; import 'package:tuple/tuple.dart'; import 'package:window_size/window_size.dart'; -void main() async { - WidgetsFlutterBinding.ensureInitialized(); - Directory.current = gCurrentDirectoy; - setWindowTitle('Quickgui : a flutter frontend for Quickget and Quickemu'); - setWindowMinSize(const Size(692, 580)); - setWindowMaxSize(const Size(692, 580)); - gOperatingSystems = await loadOperatingSystems(false); - - runApp(const App()); -} - Future> loadOperatingSystems(bool showUbuntus) async { var process = await Process.run('quickget', ['list_csv']); var stdout = process.stdout as String; @@ -52,3 +41,14 @@ Future> loadOperatingSystems(bool showUbuntus) async { return output; } + +void main() async { + WidgetsFlutterBinding.ensureInitialized(); + Directory.current = gCurrentDirectoy; + setWindowTitle('Quickgui : a flutter frontend for Quickget and Quickemu'); + setWindowMinSize(const Size(692, 580)); + setWindowMaxSize(const Size(692, 580)); + gOperatingSystems = await loadOperatingSystems(false); + + runApp(const App()); +} diff --git a/lib/src/pages/downloader_page.dart b/lib/src/pages/downloader_page.dart new file mode 100644 index 0000000..a6ee7e3 --- /dev/null +++ b/lib/src/pages/downloader_page.dart @@ -0,0 +1,22 @@ +import 'package:flutter/material.dart'; +import 'package:quickgui/src/widgets/home_page/downloader_menu.dart'; +import 'package:quickgui/src/widgets/home_page/logo.dart'; + +class DownloaderPage extends StatelessWidget { + const DownloaderPage({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Downloader'), + ), + body: Column( + children: const [ + Logo(), + DownloaderMenu(), + ], + ), + ); + } +} diff --git a/lib/src/pages/main_page.dart b/lib/src/pages/main_page.dart index 4862666..097e493 100644 --- a/lib/src/pages/main_page.dart +++ b/lib/src/pages/main_page.dart @@ -1,9 +1,8 @@ import 'dart:io'; -import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; -import 'package:quickgui/src/globals.dart'; -import 'package:quickgui/src/widgets/home_page/home_page_button_group.dart'; +import 'package:quickgui/src/widgets/home_page/logo.dart'; +import 'package:quickgui/src/widgets/home_page/main_menu.dart'; class MainPage extends StatefulWidget { const MainPage({Key? key, required this.title}) : super(key: key); @@ -17,64 +16,20 @@ class MainPage extends StatefulWidget { class _MainPageState extends State { @override Widget build(BuildContext context) { - //Directory.current = '/home/yannick'; return Scaffold( + appBar: AppBar( + title: const Text('Main menu'), + leading: IconButton( + onPressed: () { + exit(0); + }, + icon: const Icon(Icons.exit_to_app), + ), + ), body: Column( - children: [ - SizedBox( - height: 250, - child: Flex( - direction: Axis.vertical, - children: [ - Expanded( - child: Center( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Image.asset('assets/images/logo.png'), - ), - ), - ), - ], - ), - ), - Expanded( - child: Container( - color: Colors.pink, - child: Column( - children: [ - Row( - children: [ - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: const [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: HomePageButtonGroup(), - ) - ], - ), - ), - ], - ), - InkWell( - onTap: () async { - var folder = await FilePicker.platform.getDirectoryPath(dialogTitle: "Pick a folder"); - if (folder != null) { - setState(() { - gCurrentDirectoy = Directory(folder); - }); - } - }, - child: Text( - "Working directory : ${gCurrentDirectoy.path}", - style: Theme.of(context).textTheme.subtitle1!.copyWith(color: Colors.white), - ), - ), - ], - ), - ), - ), + children: const [ + Logo(), + MainMenu(), ], ), ); diff --git a/lib/src/widgets/home_page/downloader_menu.dart b/lib/src/widgets/home_page/downloader_menu.dart new file mode 100644 index 0000000..de77eab --- /dev/null +++ b/lib/src/widgets/home_page/downloader_menu.dart @@ -0,0 +1,57 @@ +import 'dart:io'; + +import 'package:file_picker/file_picker.dart'; +import 'package:flutter/material.dart'; +import 'package:quickgui/src/globals.dart'; +import 'package:quickgui/src/widgets/home_page/home_page_button_group.dart'; + +class DownloaderMenu extends StatefulWidget { + const DownloaderMenu({Key? key}) : super(key: key); + + @override + State createState() => _DownloaderMenuState(); +} + +class _DownloaderMenuState extends State { + @override + Widget build(BuildContext context) { + return Expanded( + child: Container( + color: Colors.pink, + child: Column( + children: [ + Row( + children: [ + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: const [ + Padding( + padding: EdgeInsets.symmetric(horizontal: 12), + child: HomePageButtonGroup(), + ) + ], + ), + ), + ], + ), + InkWell( + onTap: () async { + var folder = await FilePicker.platform.getDirectoryPath(dialogTitle: "Pick a folder"); + if (folder != null) { + setState(() { + gCurrentDirectoy = Directory(folder); + }); + } + }, + child: Text( + "Working directory : ${gCurrentDirectoy.path}", + style: Theme.of(context).textTheme.subtitle1!.copyWith(color: Colors.white), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/src/widgets/home_page/logo.dart b/lib/src/widgets/home_page/logo.dart new file mode 100644 index 0000000..eb6166c --- /dev/null +++ b/lib/src/widgets/home_page/logo.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; + +class Logo extends StatelessWidget { + const Logo({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return SizedBox( + height: 250, + child: Flex( + direction: Axis.vertical, + children: [ + Expanded( + child: Center( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Image.asset('assets/images/logo.png'), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/src/widgets/home_page/main_menu.dart b/lib/src/widgets/home_page/main_menu.dart new file mode 100644 index 0000000..1a80c09 --- /dev/null +++ b/lib/src/widgets/home_page/main_menu.dart @@ -0,0 +1,41 @@ +import 'package:flutter/material.dart'; +import 'package:quickgui/src/pages/downloader_page.dart'; +import 'package:quickgui/src/widgets/home_page/home_page_button.dart'; + +class MainMenu extends StatelessWidget { + const MainMenu({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Expanded( + child: Container( + color: Colors.pink, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + HomePageButton( + onPressed: () {}, + text: 'Manage existing machines', + ), + HomePageButton( + onPressed: () { + //Navigator.of(context).push(MaterialPageRoute(builder: (context) => const DownloaderPage())); + Navigator.of(context).push( + PageRouteBuilder( + fullscreenDialog: true, + pageBuilder: (context, animation1, animation2) => const DownloaderPage(), + transitionDuration: Duration.zero, + ), + ); + }, + text: 'Create new machines', + ), + ], + ), + ), + ), + ); + } +}