import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:idrocap/private/model/userList.dart'; import 'package:idrocap/private/notifiche.dart'; import '../utility/utility.dart'; import 'constant/globals.dart' as globals; import 'widget/menu.dart'; class ProfileUser extends StatefulWidget { final UserList userList; ProfileUser({super.key, required this.userList}); @override State createState() => _ProfileUserState(); } class _ProfileUserState extends State { String searchString = ""; @override void initState() { super.initState(); } @override Widget build(BuildContext context) { return PopScope( canPop: true, child: Scaffold( appBar: AppBar( leading: InkWell( onTap: () { Navigator.pop(context); }, child: Icon( Icons.arrow_back_ios, color: Colors.white, ), ), automaticallyImplyLeading: true, iconTheme: IconThemeData(color: Colors.white), backgroundColor: HexColor(globals.colorAppbar), title: Center( child: Text( "Utenti", style: TextStyle(color: Colors.white), ), ), actions: [ IconButton( onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (context) => Notifiche())); }, icon: Icon(Icons.notifications), ) ], ), drawer: Menu(), body: SingleChildScrollView( child: Column( children: [ Padding( padding: EdgeInsets.all(8), child: Container( color: HexColor(globals.coloreCardProfili), child: Wrap(children: [ ListTile( leading: Icon( Icons.account_circle_outlined, size: 50, color: Colors.white, ), title: Wrap( children: [ Text( widget.userList.surname + " " + widget.userList.name, style: TextStyle(color: Colors.white)), ], ), subtitle: Wrap( children: [ Text( widget.userList.organisation_description + " " + widget.userList.name, style: TextStyle(color: Colors.white), ), ], ), ), ])), ), Padding( padding: EdgeInsets.all(5), child: Card( elevation: 20, child: Column( children: [ Container( decoration: BoxDecoration( borderRadius: BorderRadius.only( topRight: Radius.circular(10), topLeft: Radius.circular(10)), color: HexColor(globals.colorAppbar), ), child: ListTile( title: Wrap( children: [ Text( "Contatti disponibili", style: TextStyle( color: Colors.white, fontSize: 20), ) ], ), ), ), Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(10), bottomRight: Radius.circular(10)), ), //color: Colors.white, child: Padding( padding: EdgeInsets.all(15), child: Column( children: [ if (widget.userList.username.isNotEmpty) Align( alignment: Alignment.topLeft, child: Wrap( alignment: WrapAlignment.start, children: [ Text( "Nome utente: ", style: TextStyle( fontWeight: FontWeight.bold), ), Text(widget.userList.username), ], ), ), if (widget.userList.name.isNotEmpty) Align( alignment: Alignment.topLeft, child: Wrap( children: [ Text( "Nome: ", style: TextStyle( fontWeight: FontWeight.bold), ), Text( widget.userList.name, ), ], ), ), if (widget.userList.surname.isNotEmpty) Align( alignment: Alignment.topLeft, child: Wrap( alignment: WrapAlignment.start, children: [ Text( "Cognome: ", style: TextStyle( fontWeight: FontWeight.bold), ), Text(widget.userList.surname), ], ), ), if (widget.userList.birthday.isNotEmpty) Align( alignment: Alignment.topLeft, child: Wrap( alignment: WrapAlignment.start, children: [ Text( "Data di nascita: ", style: TextStyle( fontWeight: FontWeight.bold), ), Text(widget.userList.birthday), ], ), ), if (widget.userList.birthplace.isNotEmpty) Align( alignment: Alignment.topLeft, child: Wrap( alignment: WrapAlignment.start, children: [ Text( "Luogo di nascita: ", style: TextStyle( fontWeight: FontWeight.bold), ), Text(widget.userList.birthplace), ], ), ), if (widget.userList.gender.isNotEmpty) Align( alignment: Alignment.topLeft, child: Wrap( alignment: WrapAlignment.start, children: [ Text( "Sesso: ", style: TextStyle( fontWeight: FontWeight.bold), ), Text(widget.userList.gender), ], ), ), if (widget.userList.address.isNotEmpty) Align( alignment: Alignment.topLeft, child: Wrap( alignment: WrapAlignment.start, children: [ Text( "indirizzo: ", style: TextStyle( fontWeight: FontWeight.bold), ), Text(widget.userList.address), ], ), ), if (widget.userList.city.isNotEmpty) Align( alignment: Alignment.topLeft, child: Wrap( alignment: WrapAlignment.start, children: [ Text( "Città: ", style: TextStyle( fontWeight: FontWeight.bold), ), Text(widget.userList.city), ], ), ), if (widget.userList.cap.isNotEmpty) Align( alignment: Alignment.topLeft, child: Wrap( alignment: WrapAlignment.start, children: [ Text( "CAP: ", style: TextStyle( fontWeight: FontWeight.bold), ), Text(widget.userList.cap), ], ), ), if (widget.userList.organisation_description .isNotEmpty) Align( alignment: Alignment.topLeft, child: Wrap( alignment: WrapAlignment.start, children: [ Text( "Organizzazione: ", style: TextStyle( fontWeight: FontWeight.bold), ), Text(widget .userList.organisation_description), ], ), ), if (widget.userList.profiles.isNotEmpty) Align( alignment: Alignment.topLeft, child: Wrap( alignment: WrapAlignment.start, children: [ Text( "Profili: ", style: TextStyle( fontWeight: FontWeight.bold), ), Text(widget.userList.profiles), ], ), ), Divider(), if (widget.userList.phones.length > 0 || widget.userList.mobile_phones.length > 0) Row( children: [ Text( "Numeri di telefono", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 18), ), ], ), SizedBox( height: 20, ), for (int i = 0; i < widget.userList.phones.length; i++) Container( child: Column( children: [ Row( children: [ Text(widget.userList.phones[i] ['type']), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(widget.userList.phones[i] ['value']), IconButton( icon: Icon(Icons.phone), color: Colors.green, onPressed: () async { await Utility.makePhoneCall( widget.userList.phones[i] ['value']); }, ) ], ), Divider(), ], ), ), for (int i = 0; i < widget.userList.mobile_phones.length; i++) Container( child: Column( children: [ Row( children: [ Text(widget.userList .mobile_phones[i]['type']), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(widget.userList .mobile_phones[i]['value']), IconButton( icon: Icon(Icons.phone), color: Colors.green, onPressed: () async { await Utility.makePhoneCall( widget.userList .mobile_phones[i] ['value']); }, ) ], ), Divider(), ], ), ), SizedBox( height: 20, ), if (widget.userList.emails.length > 0) Row( children: [ Text( "E-mail", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 18), ), ], ), SizedBox( height: 20, ), for (int i = 0; i < widget.userList.emails.length; i++) Container( child: Column( children: [ Row( children: [ Text(widget.userList.emails[i] ['type']), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(widget.userList.emails[i] ['value']), IconButton( icon: Icon(Icons.email), color: Colors.red, onPressed: () async { await Utility.makeEmail(widget .userList .emails[i]['value']); }, ) ], ), Divider(), ], ), ), ], ), ), ), ], )), ) ], ), ), ), ); } }