improve the auth header

merge-requests/1/merge
Elham Rababah 6 years ago
parent 1abdf8e721
commit 24c87dc2b1

@ -0,0 +1 @@
enum loginType { knownUser, unknownUser }

@ -1,4 +1,4 @@
import 'package:doctor_app_flutter/models/category_models.dart';
import 'package:doctor_app_flutter/models/category_models.dart';
import 'package:doctor_app_flutter/routes.dart';
const DUMMY_CATEGORIES = const [

@ -1,5 +1,6 @@
import 'dart:async';
import 'package:doctor_app_flutter/lookups/auth_lookup.dart';
import 'package:doctor_app_flutter/widgets/auth/known_user_login.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
@ -12,6 +13,7 @@ class Loginsreen extends StatefulWidget {
_LoginsreenState createState() => _LoginsreenState();
}
class _LoginsreenState extends State<Loginsreen> {
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
@ -54,10 +56,23 @@ class _LoginsreenState extends State<Loginsreen> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
AuthHeader(),
(platformImei == null)
? LoginForm()
: KnownUserLogin(),
? Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
AuthHeader(loginType.knownUser),
LoginForm(),
],
)
: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
AuthHeader(loginType.unknownUser),
KnownUserLogin(),
],
),
]));
}
}

@ -1,100 +1,125 @@
import 'package:doctor_app_flutter/lookups/auth_lookup.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_device_type/flutter_device_type.dart';
class AuthHeader extends StatelessWidget {
const AuthHeader({
Key key,
}) : super(key: key);
var userType;
AuthHeader(this.userType);
@override
Widget build(BuildContext context) {
print(Device.get().isPhone);
print(Device.get().isAndroid);
print(Device.get().isIos);
var smallScreenSize = 660;
return LayoutBuilder(builder: (ctx, constraints) {
bool isSmallScreen = constraints.maxWidth<=smallScreenSize;
bool isSmallScreen = constraints.maxWidth <= smallScreenSize;
var screen = Container(
margin: isSmallScreen?null:EdgeInsetsDirectional.fromSTEB(constraints.maxWidth*0.30, constraints.maxWidth*0.1, 0, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: isSmallScreen?EdgeInsetsDirectional.fromSTEB(0, 50, 0, 0):EdgeInsetsDirectional.fromSTEB(constraints.maxWidth*0.13, 0, 0, 0),
child: Image.asset(
'assets/images/login_icon.png',
fit: BoxFit.cover,
height: isSmallScreen?null: constraints.maxWidth*0.09,
),
),
SizedBox(
height: 10,
),
Container(
margin: isSmallScreen?null:EdgeInsetsDirectional.fromSTEB(constraints.maxWidth*0.13, 0, 0, 0),
child: Text(
"LOGIN",
style: TextStyle(fontSize: isSmallScreen?30:constraints.maxWidth*0.035, fontWeight: FontWeight.w800),
margin: isSmallScreen
? null
: EdgeInsetsDirectional.fromSTEB(constraints.maxWidth * 0.30,
constraints.maxWidth * 0.1, 0, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: isSmallScreen
? EdgeInsetsDirectional.fromSTEB(0, 50, 0, 0)
: EdgeInsetsDirectional.fromSTEB(
constraints.maxWidth * 0.13, 0, 0, 0),
child: Image.asset(
'assets/images/login_icon.png',
fit: BoxFit.cover,
height:
isSmallScreen ? null : constraints.maxWidth * 0.09,
),
),
SizedBox(
height: 10,
),
Container(
margin: isSmallScreen
? null
: EdgeInsetsDirectional.fromSTEB(
constraints.maxWidth * 0.13, 0, 0, 0),
child: Text(
"LOGIN",
style: TextStyle(
fontSize:
isSmallScreen ? 30 : constraints.maxWidth * 0.035,
fontWeight: FontWeight.w800),
),
)
],
),
)
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: isSmallScreen?<Widget>[
SizedBox(
height: 10,
),
Text(
"Welcome to",
style: TextStyle(fontSize: isSmallScreen?24:constraints.maxWidth*0.029),
),
Text(
'Dr Sulaiman Al Habib',
style: TextStyle(
fontSize: isSmallScreen?24:constraints.maxWidth*0.029,
color: Theme.of(context).primaryColor,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: isSmallScreen
? <Widget>[
SizedBox(
height: 10,
),
buildWelText(isSmallScreen, constraints),
buildDrSulText(isSmallScreen, constraints, context),
]
: <Widget>[
SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
buildWelText(isSmallScreen, constraints),
buildDrSulText(isSmallScreen, constraints, context),
],
),
],
),
),
]:<Widget>[SizedBox(
height: 10,
),Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text(
"Welcome to ",
style: TextStyle(fontSize: isSmallScreen?24:constraints.maxWidth*0.029),
),
Text(
'Dr Sulaiman Al Habib',
style: TextStyle(
fontSize: isSmallScreen?24:constraints.maxWidth*0.029,
color: Theme.of(context).primaryColor,
),
),
],
),Container(
margin: isSmallScreen?null:EdgeInsetsDirectional.fromSTEB(constraints.maxWidth*0.13, 0, 0, 0),
child: Text(
"Doctor App",
style: TextStyle(
fontSize: isSmallScreen?26:constraints.maxWidth*0.030, color: Theme.of(context).primaryColor),
),
)],
)
],
));
buildDrAppContainer(isSmallScreen, constraints, context)
],
));
return screen;
});
}
Container buildDrAppContainer(
bool isSmallScreen, BoxConstraints constraints, BuildContext context) {
return Container(
margin: isSmallScreen
? null
: EdgeInsetsDirectional.fromSTEB(
constraints.maxWidth * 0.13, 0, 0, 0),
child: Text(
"Doctor App",
style: TextStyle(
fontSize: isSmallScreen ? 26 : constraints.maxWidth * 0.030,
color: Theme.of(context).primaryColor),
),
);
}
Text buildDrSulText(
bool isSmallScreen, BoxConstraints constraints, BuildContext context) {
return Text(
'Dr Sulaiman Al Habib',
style: TextStyle(
fontSize: isSmallScreen ? 24 : constraints.maxWidth * 0.029,
color: Theme.of(context).primaryColor,
),
);
}
Text buildWelText(bool isSmallScreen, BoxConstraints constraints) {
String text = 'Welcome to ';
if (userType == loginType.unknownUser) {
text = 'Welcome Back to';
}
return Text(
text,
style: TextStyle(
fontSize: isSmallScreen ? 24 : constraints.maxWidth * 0.029),
);
}
}

Loading…
Cancel
Save