Initial commit
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mensaappbackend/providers/pageProvider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
await Supabase.initialize(
|
||||
url: "http://192.168.188.29:8000",
|
||||
anonKey: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE"
|
||||
);
|
||||
|
||||
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 MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => PageProvider(),
|
||||
)
|
||||
],
|
||||
child: MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: ThemeData(
|
||||
colorScheme: const ColorScheme(
|
||||
primary: Color.fromRGBO(236, 92, 61, 1),
|
||||
onPrimary: Color.fromRGBO(240, 240, 240, 1),
|
||||
secondary: Color.fromRGBO(203, 203, 203, 1),
|
||||
onSecondary: Color.fromRGBO(60, 60, 60, 1),
|
||||
error: Colors.red,
|
||||
onError: Colors.white,
|
||||
surface: Colors.white,
|
||||
onSurface: Color.fromRGBO(60, 60, 60, 1),
|
||||
brightness: Brightness.light,
|
||||
tertiary: Color.fromRGBO(251, 216, 17, 1),
|
||||
onTertiary: Color.fromRGBO(60, 60, 60, 1)),
|
||||
useMaterial3: true,
|
||||
),
|
||||
home: const MyHome()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyHome extends StatefulWidget {
|
||||
const MyHome({super.key});
|
||||
|
||||
@override
|
||||
State<MyHome> createState() => _MyHomeState();
|
||||
}
|
||||
|
||||
class _MyHomeState extends State<MyHome> {
|
||||
|
||||
bool initial = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
initial = true;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var supabase = Supabase.instance.client;
|
||||
|
||||
if (initial) {
|
||||
initial = false;
|
||||
if (supabase.auth.currentSession == null) {
|
||||
Provider.of<PageProvider>(context, listen: false).selectedPage = 0;
|
||||
print("not logged in");
|
||||
} else if (supabase.auth.currentSession!.isExpired) {
|
||||
Provider.of<PageProvider>(context, listen: false).selectedPage = 0;
|
||||
print("expired");
|
||||
} else {
|
||||
Provider.of<PageProvider>(context, listen: false).selectedPage = 1;
|
||||
print("logged in");
|
||||
}
|
||||
}
|
||||
|
||||
return Consumer<PageProvider>(
|
||||
builder: (context, pageProvider, child) {
|
||||
return pageProvider.pages[pageProvider.selectedPage];
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user