tstor/ui/lib/main.dart
2024-05-13 19:56:20 +03:00

75 lines
2.1 KiB
Dart

import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/material.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:tstor_ui/api/client.dart';
import 'package:tstor_ui/screens/downloads.dart';
import 'package:tstor_ui/screens/file_view.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return DynamicColorBuilder(builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) {
return MaterialApp(
title: 'tStor',
theme: lightDynamic != null ? ThemeData.from(colorScheme: lightDynamic) : ThemeData.light(),
darkTheme:
darkDynamic != null ? ThemeData.from(colorScheme: darkDynamic) : ThemeData.dark(),
routes: {
"/home": (context) => const HomePage(),
// "/files": (context) => const FileViewScreen(),
},
initialRoute: "/home",
home: GraphQLProvider(
client: ValueNotifier(client),
child: const HomePage(),
),
);
});
}
}
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int currentPageIndex = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: <Widget>[
const FileViewScreen(),
const DownloadsScreen(),
][currentPageIndex],
bottomNavigationBar: BottomNavigationBar(
currentIndex: currentPageIndex,
onTap: (i) => setState(() {
currentPageIndex = i;
}),
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.folder_copy_outlined),
activeIcon: Icon(Icons.folder_copy),
label: 'Files',
),
BottomNavigationBarItem(
icon: Icon(Icons.download_outlined),
activeIcon: Icon(Icons.download),
label: 'Downloads',
),
],
),
);
}
}