Skip to content

Commit

Permalink
login screen done, untested
Browse files Browse the repository at this point in the history
  • Loading branch information
romme86 committed May 20, 2022
1 parent e6a126d commit 0576c59
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 57 deletions.
4 changes: 4 additions & 0 deletions vidaia/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"dart.lineLength": 3000,
"html.format.wrapLineLength": 1200
}
Binary file added vidaia/assets/images/plant_background.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 13 additions & 4 deletions vidaia/lib/pages/home/home_page_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import 'package:vidaia/main.dart';
import 'package:vidaia/pages/home/history/buy_history_page.dart';
import 'package:vidaia/pages/home/home/home_page.dart';
import 'package:vidaia/pages/home/redeem/redeem_page.dart';
import 'package:vidaia/pages/login_page.dart';
import 'package:vidaia/repositories/dataRepository.dart';
import 'package:vidaia/services/auth_service.dart';

import 'home_page_stack.dart';

Expand All @@ -16,23 +18,28 @@ class HomePage2 extends StatefulWidget {

class _HomePage2State extends State<HomePage2> {
late Future<bool> isDataLoaded;
late Future<bool> isUserLogged;

DataRepository dataRepository = getIt.get<DataRepository>();

@override
void initState() {
super.initState();
// isUserLogged = AuthService.instance.init();
isDataLoaded = dataRepository.init();
}

final _pages = [HomePage(), BuyHistoryPage(), RedeemPage()];

@override
Widget build(BuildContext context) {
return FutureBuilder<bool>(
future: isDataLoaded,
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
if (snapshot.connectionState == ConnectionState.done && snapshot.data == true) {
return FutureBuilder<List<bool>>(
future: Future.wait([
// isUserLogged, //Future that returns bool
isDataLoaded, //Future that returns bool
]),
builder: (BuildContext context, AsyncSnapshot<List<bool>> snapshot) {
if (snapshot.connectionState == ConnectionState.done && AuthService.instance.profile!.id.isNotEmpty && snapshot.data?[0] == true) {
return HomePageStack(_pages);
} else if (snapshot.connectionState == ConnectionState.done && snapshot.hasError) {
return Padding(
Expand All @@ -42,6 +49,8 @@ class _HomePage2State extends State<HomePage2> {
style: TextStyle(fontSize: 20),
),
);
} else if (snapshot.data?[0] == false) {
return const LoginPage();
} else {
return Center(
child: Column(
Expand Down
114 changes: 61 additions & 53 deletions vidaia/lib/pages/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,60 +71,68 @@ class _LoginPageState extends State<LoginPage> {
@override
Widget build(BuildContext context) {
return Container(
color: primaryColor,
child: Column(
children: [
// FlutterLogin(
// userType: LoginUserType.name,
// logo: const AssetImage('assets/images/vidaia-live-sustainably.png'),
// messages:
// LoginMessages(userHint: 'Email', passwordHint: 'password'.tr()),
// onLogin: _authUser,
// onSignup: _signupUser,
// onSubmitAnimationCompleted: () {
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) => HomePage2()),
// );
// if (!mnemonicNoted) {
// showMnemonicAlert(context);
// }
// },
// onRecoverPassword: _recoverPassword,
// ),
TextButton(
onPressed: loginAction,
child: const Text('Auth0 Login | Register'),
decoration: const BoxDecoration(
image: DecorationImage(alignment: Alignment.centerLeft, image: AssetImage('assets/images/plant_background.jpeg'), fit: BoxFit.cover),
),
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(colors: [DARK_GRADIENT, TRANSPARENT_GRADIENT], begin: Alignment.bottomCenter, end: Alignment.center),
),
child: Padding(
padding: const EdgeInsets.all(30.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
if (isProgressing)
CircularProgressIndicator()
else if (!isLoggedIn)
Column(
children: [
const Text(
'Have it greener with Vidaia.',
textAlign: TextAlign.left,
style: TextStyle(fontSize: 25, color: TEXT_WHITE, decoration: TextDecoration.none),
),
const SizedBox(
height: 30,
),
ElevatedButton(
onPressed: loginAction,
child: const Text('Login | Register'),
style: elevatedButtonStyle,
),
const SizedBox(height: 10),
OutlinedButton(
onPressed: loginAction,
child: const Text('Skip for now'),
style: outlinedButtonStyle,
),
const SizedBox(height: 30),
],
)
else
Expanded(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'Welcome $name',
textAlign: TextAlign.center,
style: const TextStyle(color: TEXT_WHITE, decoration: TextDecoration.none),
),
const Icon(
Icons.done,
color: PRIMARY_LIGHT,
size: 130.0,
),
],
)),
),
],
),
if (isProgressing)
CircularProgressIndicator()
else if (!isLoggedIn)
TextButton(
onPressed: loginAction,
child: const Text('Auth0 Login | Register'),
)
else
Expanded(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'Welcome $name',
textAlign: TextAlign.center,
style: const TextStyle(
color: TEXT_WHITE, decoration: TextDecoration.none),
),
const Icon(
Icons.done,
color: PRIMARY_LIGHT,
size: 130.0,
),
],
)),
),
],
),
),
);
}
Expand Down
23 changes: 23 additions & 0 deletions vidaia/lib/utils/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,28 @@ const Color SPEND = Color.fromARGB(255, 245, 124, 102);
const Color BACKGROUND = Color(0xfff8faf7);
const Color BACKGROUND_SHADE = Color(0xffebeeea);
const Color SECONDARY = Color.fromARGB(255, 197, 197, 197);
const Color DARK_GRADIENT = Color.fromARGB(255, 0, 0, 0);
const Color TRANSPARENT_GRADIENT = Color.fromARGB(0, 0, 0, 0);

const Color TEXT_WHITE = Color(0xfff8faf7);

final ButtonStyle elevatedButtonStyle = ElevatedButton.styleFrom(
onPrimary: TEXT_WHITE,
textStyle: const TextStyle(color: TEXT_WHITE),
primary: PRIMARY_LIGHT,
minimumSize: const Size.fromHeight(36),
padding: const EdgeInsets.symmetric(horizontal: 16.0),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(2.0)),
),
);
final ButtonStyle outlinedButtonStyle = OutlinedButton.styleFrom(
textStyle: const TextStyle(color: TEXT_WHITE),
primary: TEXT_WHITE,
minimumSize: const Size.fromHeight(36),
padding: const EdgeInsets.symmetric(horizontal: 16.0),
side: BorderSide(width: 1.0, color: TEXT_WHITE),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(2.0)),
),
);
1 change: 1 addition & 0 deletions vidaia/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ flutter:
- assets/images/migros.png
- assets/images/coop.png
- assets/images/vidar.png
- assets/images/plant_background.jpeg


# An image asset can refer to one or more resolution-specific "variants", see
Expand Down

0 comments on commit 0576c59

Please sign in to comment.