52 lines
1.6 KiB
Dart
52 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:grpc/grpc_web.dart';
|
|
import 'package:softplayer_web/components/menubar.dart';
|
|
import 'package:softplayer_web/helpers/page_wrapper.dart';
|
|
import 'package:softplayer_web/pages/about.dart';
|
|
import 'package:softplayer_web/pages/catalog.dart';
|
|
import 'package:softplayer_web/pages/home.dart';
|
|
|
|
void main() async {
|
|
const String backendURL = String.fromEnvironment(
|
|
'SOFTPLAYER_BACKEND_URL',
|
|
defaultValue: 'http://softplayer.badhouseplants.net:8080',
|
|
);
|
|
GrpcWebClientChannel grpcChannel =
|
|
GrpcWebClientChannel.xhr(Uri.parse(backendURL));
|
|
|
|
runApp(MyApp(channel: grpcChannel));
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key, required this.channel});
|
|
|
|
// A channel that should be used to fire grpc calls
|
|
final GrpcWebClientChannel channel;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
title: 'Softplayer',
|
|
routes: {
|
|
'/': (context) => const PageWrapper(
|
|
appBar: MenuPanel(tab: TabName.home),
|
|
child: HomePage(),
|
|
),
|
|
'/catalog': (context) => const PageWrapper(
|
|
appBar: MenuPanel(tab: TabName.catalog),
|
|
child: CatalogPage(),
|
|
),
|
|
'/about': (context) => const PageWrapper(
|
|
appBar: MenuPanel(tab: TabName.about),
|
|
child: AboutPage(),
|
|
)
|
|
},
|
|
theme: ThemeData(
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
|
useMaterial3: true,
|
|
),
|
|
);
|
|
}
|
|
}
|