Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- signUp.dart
- ==================
- import 'package:flutter/material.dart';
- import 'package:provider/provider.dart';
- import 'package:flutter/services.dart';
- import 'package:hebo_mobile/screens/signUp/firstScreen.dart';
- import 'package:hebo_mobile/screens/signUp/secondScreen.dart';
- import 'package:hebo_mobile/screens/signUp/thirdScreen.dart';
- import 'package:hebo_mobile/screens/signUp/fourthScreen.dart';
- import 'package:hebo_mobile/screens/signUp/fifthScreen.dart';
- import 'package:hebo_mobile/screens/signUp/sixthScreen.dart';
- import 'package:hebo_mobile/screens/signUp/seventhScreen.dart';
- class SignUp extends StatefulWidget {
- @override
- SignUpState createState() => new SignUpState();
- }
- class SignUpState extends State<SignUp> {
- PageController pageCtr = PageController();
- String firstName;
- String lastName;
- String dateBirth;
- int gender;
- String email;
- String phoneCode;
- String phoneNumber;
- @override
- void dispose() {
- // Clean up the controller when the widget is removed from the
- // widget tree.
- // firstNameCtr.dispose();
- // lastNameCtr.dispose();
- // dateBirthCtr.dispose();
- super.dispose();
- }
- _firstScreenUpdate(val1, val2) {
- setState(() {
- firstName = val1;
- lastName = val2;
- });
- }
- _secondScreenUpdate(val1, val2) {
- setState(() {
- dateBirth = val1;
- gender = val2;
- });
- }
- _thirdScreenUpdateGender(val1, val2, val3) {
- setState(() {
- email = val1;
- phoneCode = val2;
- phoneNumber = val3;
- });
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: SafeArea(
- child: PageView(
- physics: new NeverScrollableScrollPhysics(),
- controller: pageCtr,
- children: <Widget>[
- Container(
- child: SignUpFirst(
- nextPage: () {
- pageCtr.nextPage(
- curve: Curves.ease, duration: Duration(milliseconds: 500));
- },
- updateValue: _firstScreenUpdate,
- firstName: firstName,
- lastName: lastName,
- ),
- ),
- Container(
- child: SignUpSecond(
- prevPage: () {
- pageCtr.previousPage(
- curve: Curves.ease, duration: Duration(milliseconds: 500));
- },
- nextPage: () {
- pageCtr.nextPage(
- curve: Curves.ease, duration: Duration(milliseconds: 500));
- },
- updateValue: _secondScreenUpdate,
- dateBirth: dateBirth,
- gender: gender,
- ),
- ),
- Container(
- child: SignUpThird(
- prevPage: () {
- pageCtr.previousPage(
- curve: Curves.ease, duration: Duration(milliseconds: 500));
- },
- nextPage: () {
- pageCtr.nextPage(
- curve: Curves.ease, duration: Duration(milliseconds: 500));
- },
- updateValue: _thirdScreenUpdateGender,
- email: email,
- phoneCode: phoneCode,
- phoneNumber: phoneNumber,
- ),
- ),
- ],
- )),
- );
- }
- }
- firstScreen.dart
- =============
- import 'package:flutter/material.dart';
- class SignUpFirst extends StatefulWidget {
- final Function nextPage;
- final Function updateValue;
- final String firstName;
- final String lastName;
- SignUpFirst(
- {@required this.nextPage,
- @required this.updateValue,
- @required this.firstName,
- @required this.lastName});
- @override
- SignUpFirstState createState() => new SignUpFirstState();
- }
- class SignUpFirstState extends State<SignUpFirst> {
- @override
- Widget build(BuildContext context) {
- TextEditingController firstNameCtr =
- new TextEditingController(text: widget.firstName);
- TextEditingController lastNameCtr =
- new TextEditingController(text: widget.lastName);
- return Scaffold(
- body: SafeArea(
- child: Container(
- width: double.infinity,
- color: Colors.pink,
- child: Padding(
- padding: const EdgeInsets.only(left: 20, right: 20, top: 20),
- child: Column(
- children: <Widget>[
- Row(
- children: <Widget>[
- FlatButton(
- onPressed: () {
- // pageCtr.previousPage(
- // curve: Curves.ease,
- // duration: Duration(milliseconds: 500));
- },
- color: Colors.transparent,
- child: Column(
- children: <Widget>[
- Icon(
- Icons.keyboard_arrow_left,
- color: Colors.white,
- size: 50,
- )
- ],
- ),
- ),
- ],
- ),
- Text(
- 'Halo, Tak Kenal maka Tak Sayang.',
- style: TextStyle(
- color: Colors.white,
- fontSize: 23,
- fontWeight: FontWeight.bold),
- ),
- TextField(
- controller: firstNameCtr,
- decoration: InputDecoration(
- enabledBorder: UnderlineInputBorder(
- borderSide: BorderSide(color: Colors.white),
- ),
- hintText: 'First Name',
- hintStyle: TextStyle(
- color: Colors.white, fontWeight: FontWeight.bold)),
- ),
- TextField(
- controller: lastNameCtr,
- decoration: InputDecoration(
- enabledBorder: UnderlineInputBorder(
- borderSide: BorderSide(color: Colors.white),
- ),
- hintText: 'Last Name',
- hintStyle: TextStyle(
- color: Colors.white, fontWeight: FontWeight.bold)),
- ),
- RaisedButton(
- onPressed: () {
- widget.nextPage();
- widget.updateValue(firstNameCtr.text, lastNameCtr.text);
- },
- child: Text('Continue'),
- ),
- ],
- ),
- ),
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement