Skip to content

Commit

Permalink
Added Splash and CheckEmail page
Browse files Browse the repository at this point in the history
  • Loading branch information
JideGuru committed Jul 8, 2020
1 parent f8ae7e9 commit d63eb06
Show file tree
Hide file tree
Showing 23 changed files with 583 additions and 136 deletions.
28 changes: 28 additions & 0 deletions lib/components/animations/fade_page_route.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:flutter/material.dart';

class FadePageRoute<T> extends PageRoute<T> {
FadePageRoute(this.child);

@override
Color get barrierColor => Colors.white10;

@override
String get barrierLabel => null;

final Widget child;

@override
Widget buildPage(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
return FadeTransition(
opacity: animation,
child: child,
);
}

@override
bool get maintainState => true;

@override
Duration get transitionDuration => Duration(milliseconds: 500);
}
69 changes: 69 additions & 0 deletions lib/components/animations/type_write.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import 'package:flutter/material.dart';

class TypeWrite extends StatefulWidget {
final String word;
final TextStyle style;
final double textScaleFactor;
final int seconds;

TypeWrite({
Key key,
this.word,
this.style,
this.textScaleFactor,
this.seconds = 4,
}) : super(key: key);

@override
_TypeWriteState createState() => _TypeWriteState();
}

class _TypeWriteState extends State<TypeWrite> with TickerProviderStateMixin {
@override
void initState() {
super.initState();
animate();
}

AnimationController controller;

animate() async {
controller = AnimationController(
duration: Duration(seconds: widget.seconds),
vsync: this,
);
setState(() {
_stringIndex = _stringIndex == null ? 0 : _stringIndex + 1;
_characterCount = StepTween(begin: 0, end: widget.word.length)
.animate(CurvedAnimation(parent: controller, curve: Curves.easeIn));
});

await controller.forward();
}

Animation<int> _characterCount;

int _stringIndex;

@override
void dispose() {
controller.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _characterCount,
builder: (BuildContext context, Widget child) {
String text = widget.word.substring(0, _characterCount.value);
return Text(
text,
style: widget.style,
textScaleFactor: widget.textScaleFactor,
textAlign: TextAlign.center,
);
},
);
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:social_app_ui/screens/conversation.dart';
import 'package:social_app_ui/screens/chat/conversation.dart';


class ChatItem extends StatefulWidget {
Expand Down
42 changes: 42 additions & 0 deletions lib/components/custom_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';

class CustomButton extends StatelessWidget {
final String label;
final Function onPressed;
final Color color;

CustomButton({
this.label = 'Continue',
this.onPressed,
this.color,
});

bool isSmallScreen(BuildContext context) {
return MediaQuery.of(context).size.width < 800;
}

@override
Widget build(BuildContext context) {
return Container(
height: 50.0,
width: MediaQuery.of(context).size.width,
child: FlatButton(
onPressed: onPressed,
color: color??Theme.of(context).accentColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
),
child: Text(
"$label",
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 18.0,
color: Colors.white,
),
),
),
);
}
}
85 changes: 85 additions & 0 deletions lib/components/custom_text_field.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import 'package:flutter/material.dart';

class CustomTextField extends StatelessWidget {
final String initialValue;
final bool enabled;
final String hintText;
final TextInputType textInputType;
final TextEditingController controller;
final TextInputAction textInputAction;
final FocusNode focusNode, nextFocusNode;
final VoidCallback submitAction;
final bool obscureText;
final FormFieldValidator<String> validateFunction;
final void Function(String) onSaved, onChange;
final Key key;


CustomTextField({
this.initialValue,
this.enabled,
this.hintText,
this.textInputType,
this.controller,
this.textInputAction,
this.focusNode,
this.nextFocusNode,
this.submitAction,
this.obscureText = false,
this.validateFunction,
this.onSaved,
this.onChange,
this.key});

@override
Widget build(BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width,
child: TextFormField(
initialValue: initialValue,
enabled: enabled,
onChanged: onChange,
style: TextStyle(
fontSize: 15.0,
),
key: key,
controller: controller,
obscureText: obscureText,
keyboardType: textInputType,
validator: validateFunction,
onSaved: onSaved,
textInputAction: textInputAction,
focusNode: focusNode,
onFieldSubmitted: (String term) {
if (nextFocusNode != null) {
focusNode.unfocus();
FocusScope.of(context).requestFocus(nextFocusNode);
} else {
submitAction();
}
},
decoration: InputDecoration(
hintText: hintText,
hintStyle: TextStyle(
color: Colors.grey[400],
),
contentPadding: EdgeInsets.symmetric(horizontal: 20.0),
border: border(),
focusedBorder: border()
),
),
);
}

border(){
return OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
borderSide: BorderSide(
color: Color(0xffB3ABAB),
width: 1.0,
),
);
}
}
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:social_app_ui/screens/main_screen.dart';
import 'package:social_app_ui/screens/splash/splash.dart';
import 'package:social_app_ui/util/const.dart';
import 'package:social_app_ui/util/theme_config.dart';

void main() async{
void main() async {
runApp(MyApp());
}

Expand All @@ -20,8 +20,8 @@ class _MyAppState extends State<MyApp> {
debugShowCheckedModeBanner: false,
title: Constants.appName,
theme: themeData(ThemeConfig.lightTheme),
darkTheme: themeData(ThemeConfig.darkTheme),
home: MainScreen(),
// darkTheme: themeData(ThemeConfig.darkTheme),
home: Splash(),
);
}

Expand Down
109 changes: 109 additions & 0 deletions lib/screens/auth/check_email.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import 'package:flutter/material.dart';
import 'package:social_app_ui/components/custom_button.dart';
import 'package:social_app_ui/components/custom_text_field.dart';
import 'package:social_app_ui/util/const.dart';
import 'package:social_app_ui/util/validations.dart';

class CheckEmail extends StatefulWidget {
@override
_CheckEmailState createState() => _CheckEmailState();
}

class _CheckEmailState extends State<CheckEmail> {
bool loading = false;
bool validate = false;
GlobalKey<FormState> formKey = GlobalKey<FormState>();
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
String email = '';

checkEmail() async{
FormState form = formKey.currentState;
form.save();
if (!form.validate()) {
validate = true;
showInSnackBar('Please fix the errors in red before submitting.');
}else{

}
}

void showInSnackBar(String value) {
_scaffoldKey.currentState.removeCurrentSnackBar();
_scaffoldKey.currentState
.showSnackBar(SnackBar(content: Text(value)));
}

@override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
body: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Hero(
tag: 'appname',
child: Material(
type: MaterialType.transparency,
child: Text(
'${Constants.appName}',
style: TextStyle(
fontSize: 40.0,
fontWeight: FontWeight.bold,
),
),
),
),

SizedBox(
height: 100.0,
),

Text(
'Please input your email address',
style: TextStyle(
fontSize: 15.0,
),
),

SizedBox(
height: 12.0,
),

Form(
autovalidate: validate,
key: formKey,
child: CustomTextField(
enabled: !loading,
hintText: "jideguru@gmail.com",
textInputAction: TextInputAction.done,
validateFunction: Validations.validateEmail,
submitAction: checkEmail,
onSaved: (String val) {
email = val;
},
),
),

SizedBox(
height: 20.0,
),
buildButton(),
],
),
),
),
);
}

buildButton() {
return loading
? Center(child: CircularProgressIndicator())
: CustomButton(
label: "Continue",
onPressed: () => checkEmail(),
);
}
}
Loading

0 comments on commit d63eb06

Please sign in to comment.