Connexion
Connexion
dart';
void main() {
runApp(const MyApp());
}
@override
State<MyHomePage> createState() => _MyHomePageState();
}
int selectedIndex = 0;
final nameController = TextEditingController();
String? sexe;
bool music = false;
bool mangas = false;
bool football = false;
final formKey = GlobalKey<FormState>();
String name = "Jonh Doe";
bool loading = false;
bool displayInfo = false;
displayDialog(BuildContext context) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text("Confirmation"),
content: Text("Etes-vous sur de vouloir soumettre ce formulaire ?"),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text("Annuler")
),
TextButton(
onPressed: () {
Navigator.pop(context);
setState(() {
loading = true;
});
Future.delayed(Duration(seconds: 5), () {
setState(() {
loading = false;
name = nameController.text;
displayInfo = true;
});
});
},
child: Text("Ok")
),
],
);
}
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.redAccent,
title: Text('Titre de la page', style: TextStyle(color: Colors.white),),
actions: [
IconButton(onPressed: null, icon: Icon(Icons.add_alert, color:
Colors.white)),
IconButton(onPressed: null, icon: Icon(Icons.search, color:
Colors.white))
],
),
drawer: Drawer(
child: ListView(
children: [
DrawerHeader(
child: Column(
children: [
CircleAvatar(
child: Text(name.substring(0, 2), style: TextStyle(fontSize:
40, color: Colors.white),),
radius: 50.0,
backgroundColor: Colors.black54,
),
Text(name, style: TextStyle(color: Colors.white, fontSize: 20),),
],
),
decoration: BoxDecoration(
color: Colors.redAccent
),
),
ListTile(
leading: Icon(Icons.message),
title: Text("Messages"),
),ListTile(
leading: Icon(Icons.person),
title: Text("Profile"),
),ListTile(
leading: Icon(Icons.settings),
title: Text("Paramètres"),
),
],
),
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: selectedIndex,
selectedItemColor: Colors.redAccent,
onTap: (int index) {
setState(() {
selectedIndex = index;
});
},
items: const<BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Inscription'
),
BottomNavigationBarItem(
icon: Icon(Icons.info),
label: 'Information'
),
BottomNavigationBarItem(
icon: Icon(Icons.settings),
label: 'Paramètres'
),
],
),
floatingActionButton: FloatingActionButton(
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Floating bouton cliqué"))
);
},
backgroundColor: Colors.redAccent,
],
),
SizedBox(height: 10,),
ElevatedButton(
onPressed: () {
if(formKey.currentState!.validate()) {
displayDialog(context);
}
},
child: loading ? SizedBox(
height: 30,
width: 30,
child: CircularProgressIndicator(
strokeWidth: 2,
),
) : Text("Valider")
)
],
)
)
],
),
),
),
);
}
}