This commit is contained in:
2021-01-23 19:28:26 -05:00
parent fec7db1890
commit 4378a2927b
51 changed files with 992 additions and 245 deletions

View File

@@ -0,0 +1,70 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:imagini/blocs/login/bloc.dart';
import 'package:imagini/blocs/login/states.dart';
import 'package:imagini/blocs/login/events.dart';
import 'package:imagini/blocs/theme/bloc.dart';
import 'package:imagini/blocs/theme/events.dart';
import 'package:imagini/settings/preferences.dart';
import 'package:imagini/settings/app_themes.dart';
class LoginScreen extends StatefulWidget {
@override
_LoginScreenState createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
@override
void initState() {
super.initState();
_loadTheme();
_loadLogin();
}
_loadTheme() async {
context.read<ThemeBloc>().add(ThemeEvent(appTheme: Preferences.getTheme()));
}
_loadLogin() async {
context.read<LoginBloc>().add(LoginEvents.loginResult);
}
_setTheme(bool darkTheme) async {
AppTheme selectedTheme =
darkTheme ? AppTheme.lightTheme : AppTheme.darkTheme;
context.read<ThemeBloc>().add(ThemeEvent(appTheme: selectedTheme));
Preferences.saveTheme(selectedTheme);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: _body(),
);
}
_body() {
return BlocBuilder<LoginBloc, LoginState>(builder: (BuildContext context, LoginState state) {
// Set Theme
_setTheme(true);
if (state is LoginNeeded) {
// TODO: Load Login Form
return Center( child: Text("Login Needed") );
}
if (state is LoginFailed) {
// TODO: Update Form Failed
return Center( child: Text("Login Failed: ${state.error.message.toString()}") );
}
if (state is LoginSuccess) {
// TODO: Navigate to /Gallery
return Center( child: Text("Login Success") );
}
// TODO: Login Screen
return Center( child: Text("Login Loading") );
});
}
}

View File

@@ -1,16 +0,0 @@
import 'package:flutter/material.dart';
class Body extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: RaisedButton(
onPressed: () {
// Go to Login Screen
Navigator.pushNamed(context, '/Gallery');
},
child: Text('Login'),
),
);
}
}

View File

@@ -31,7 +31,7 @@ class _GalleryScreenState extends State<GalleryScreen> {
bloc: exampleBloc,
child: PlatformScaffold(
appBar: PlatformAppBar(
title: Text('Gallerys'),
title: Text('Gallery'),
cupertino: (_, __) => CupertinoNavigationBarData(
// Issue with cupertino where a bar with no transparency
// will push the list down. Adding some alpha value fixes it (in a hacky way)

View File

@@ -0,0 +1,59 @@
import 'package:flutter/material.dart';
class Body extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Container(
margin: EdgeInsets.fromLTRB(50, 0, 50, 0),
height: 500,
child: Column(
children: <Widget>[
Container(
child: FittedBox(
fit: BoxFit.contain,
child: const FlutterLogo(),
),
width: 175,
margin: EdgeInsets.fromLTRB(0, 0, 0, 50),
),
Expanded(
child: TextField(
decoration: InputDecoration(
labelText: 'Server Address'
),
),
),
Expanded(
child: TextField(
decoration: InputDecoration(
labelText: 'Username / Email'
),
),
),
Expanded(
child: TextField(
obscureText: true,
enableSuggestions: false,
autocorrect: false,
decoration: InputDecoration(
labelText: 'Password'
),
),
),
SizedBox(
width: double.infinity,
height: 50,
child: RaisedButton(
onPressed: () {
Navigator.pushNamed(context, '/Gallery');
},
child: Text('Login')
),
),
],
),
),
);
}
}

View File

@@ -28,9 +28,9 @@ class _LoginScreenState extends State<LoginScreen> {
return BlocProvider(
bloc: LoginBloc(),
child: Scaffold(
appBar: AppBar(
title: Text("Login"),
),
// appBar: AppBar(
// title: Text("Login"),
// ),
body: Body(),
),
);

View File

@@ -1,38 +0,0 @@
import 'package:flutter/material.dart';
import 'package:imagini/screens/splash/components/body.dart';
import 'package:imagini/screens/splash/splash-bloc.dart';
import 'package:imagini/bloc/bloc-prov.dart';
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
SplashBloc splashBloc;
@override
void initState() {
super.initState();
splashBloc = SplashBloc();
}
@override
void dispose() {
splashBloc.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BlocProvider(
bloc: SplashBloc(),
child: Scaffold(
appBar: AppBar(
title: Text("First Screen"),
),
body: Body(),
),
);
}
}