import 'package:flutter/material.dart'; class SignupPage extends StatefulWidget { const SignupPage({Key? key}) : super(key: key); @override State createState() => _SignupPageState(); } class _SignupPageState extends State { int _pageIndex = 0; List forms = [SignupForm1(title: '',), SignupForm2(title: '',), SignupForm3(title: '',)]; void _updatePageIndex(int newPageIndex) { if(newPageIndex == -1) { Navigator.pushNamed(context, '/'); } else if (newPageIndex == 3) { //autentification newPageIndex = 2; } else { setState(() { _pageIndex = newPageIndex; }); } } @override Widget build(BuildContext context) { return Scaffold( floatingActionButton: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ FloatingActionButton(child: Icon(Icons.navigate_before_outlined), onPressed: () => _updatePageIndex(_pageIndex - 1) ), SizedBox( width: 25, ), FloatingActionButton(child: Icon(Icons.navigate_next_outlined), onPressed: () => _updatePageIndex(_pageIndex +1 )) ], ), body: Center(child: forms[_pageIndex]), ); } } class SignupForm1 extends StatefulWidget { const SignupForm1({Key? key, required this.title}) : super(key: key); final String title; @override //_RegisterScreen createState() => _RegisterScreen(); State createState() => _SignupForm1(); } class _SignupForm1 extends State { DateTime? _dateTime; String? _dateString; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Register Screen'), ), body: Center( child: SizedBox( width: 300, child: Column(children: [ const SizedBox(height: 30), Text( 'Personal Information', style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold), ), const SizedBox(height: 30), Image.asset( 'assets/user.png', width: 150, ), const SizedBox(height: 30), TextField( decoration: InputDecoration( hintText: 'Name', ), ), const SizedBox(height: 10), TextField( decoration: InputDecoration( hintText: 'Surname', ), ), const SizedBox(height: 10), Row(children: [ Text(_dateString == null ? 'Select birthday date :' : _dateString.toString()), const SizedBox(width: 49), ElevatedButton( onPressed: () { showDatePicker( context: context, initialDate: DateTime.now(), firstDate: DateTime(1900), lastDate: DateTime(2222)) .then((date) { setState(() { _dateTime = date!; _dateString = "${date.day}/${date.month}/${date.year}"; }); }); }, child: const Text('Select date'), ), ]), const SizedBox(height: 10), ]), )), ); } } class SignupForm2 extends StatefulWidget { const SignupForm2({Key? key, required this.title}) : super(key: key); final String title; @override //_RegisterScreen createState() => _RegisterScreen(); State createState() => _SignupForm2(); } class _SignupForm2 extends State { bool isChecked = false; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Register Screen'), ), body: Center( child: SizedBox( width: 300, child: Column(children: [ const SizedBox(height: 30), Text( 'Contact Details', style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold), ), const SizedBox(height: 30), Image.asset( 'assets/communicate.png', width: 150, ), const SizedBox(height: 30), TextField( decoration: InputDecoration( hintText: 'Mail', ), ), const SizedBox(height: 10), TextField( decoration: InputDecoration( hintText: 'Phone Number', ), ), const SizedBox(height: 10), TextField( decoration: InputDecoration( hintText: 'Home Adress..', ), ), const SizedBox(height: 10), Row(children: [ Text('Anonymous'), Checkbox( checkColor: Colors.white, value: isChecked, onChanged: (bool? value) { setState(() { isChecked = value!; }); },), ]), const SizedBox(height: 10), ]), )), ); } } class SignupForm3 extends StatefulWidget { const SignupForm3({Key? key, required this.title}) : super(key: key); final String title; @override //_RegisterScreen createState() => _RegisterScreen(); State createState() => _SignupForm3(); } class _SignupForm3 extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Register Screen'), ), body: Center( child: SizedBox( width: 300, child: Column(children: [ const SizedBox(height: 30), Text( 'User details', style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold), ), const SizedBox(height: 30), Image.asset( 'assets/id-card.png', width: 150, ), const SizedBox(height: 30), TextField( decoration: InputDecoration( hintText: 'Username', ), ), const SizedBox(height: 10), TextField( decoration: InputDecoration( hintText: 'Password', ), ), const SizedBox(height: 10), TextField( decoration: InputDecoration( hintText: 'Repeat password', ), ), const SizedBox(height: 10), ]), )), ); } }