Update the env proto and fix auth

This commit is contained in:
2024-04-29 12:42:16 +02:00
parent ad259dc553
commit ddc70e5854
7 changed files with 138 additions and 75 deletions

View File

@@ -27,7 +27,7 @@ class MyApp extends StatelessWidget {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Softplayer',
home: TestAlert(channel: channel),
home: RootWidget(channel: channel),
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
@@ -36,10 +36,22 @@ class MyApp extends StatelessWidget {
}
}
class TestAlert extends StatelessWidget {
class RootWidget extends StatefulWidget {
final GrpcWebClientChannel channel;
TestAlert({super.key, required this.channel});
RootWidget({super.key, required this.channel});
late final AccountsGrpc accountsGrpc = AccountsGrpc(channel: channel);
@override
@override
State<StatefulWidget> createState() => _StateRootWidget();
}
class _StateRootWidget extends State<RootWidget> {
refresh() {
setState(() {});
}
bool isSignedIn() {
return window.localStorage.containsKey("token");
}
@@ -47,20 +59,34 @@ class TestAlert extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (!isSignedIn()) {
return Scaffold(
body: Container(
return Scaffold(
body: Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/login_background.jpg"),
fit: BoxFit.fill,
),
),
child: LoginForm(grpcChannel: channel),
child: LoginForm(
grpcChannel: widget.channel,
notifyParent: refresh,
),
));
} else {
return Scaffold(
body: EnvirnomentList(channel: channel),
appBar: AppBar(),
body: EnvirnomentList(channel: widget.channel),
appBar: AppBar(
title: const Text("Softplayer"),
actions: [
TextButton(
onPressed: () {
window.localStorage.remove("token");
window.localStorage.remove("uuid");
refresh();
},
child: const Text("sign out"))
],
),
floatingActionButton: FloatingActionButton(
onPressed: () => print("1"),
),