-
-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
583 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(), | ||
); | ||
} | ||
} |
Oops, something went wrong.