KonectarApp/lib/contacts_module/ui_screen/new_new_profile.dart

859 lines
29 KiB
Dart
Raw Normal View History

2024-10-08 12:01:59 +00:00
// import 'package:konectar_events/constants.dart';
// import 'package:konectar_events/custom_widget/text.dart';
// import 'package:konectar_events/ui_screen/engagementtab.dart';
// import 'package:konectar_events/ui_screen/interactionform/model/save_interaction.dart';
// import 'package:konectar_events/ui_screen/k2api_integrated_ui/activityk2_tab.dart';
// import 'package:konectar_events/ui_screen/k2api_integrated_ui/locationk2_tab.dart';
// import 'package:konectar_events/ui_screen/newformlist.dart';
import 'package:konectar_events/contacts_module/constants.dart';
import 'package:konectar_events/contacts_module/custom_widget/text.dart';
import 'package:konectar_events/contacts_module/ui_screen/engagementtab.dart';
import 'package:konectar_events/contacts_module/ui_screen/interactionform/model/save_interaction.dart';
import 'package:konectar_events/contacts_module/ui_screen/k2api_integrated_ui/activityk2_tab.dart';
import 'package:konectar_events/contacts_module/ui_screen/k2api_integrated_ui/locationk2_tab.dart';
import 'package:konectar_events/contacts_module/ui_screen/newformlist.dart';
import 'package:flutter/material.dart';
import 'package:flutter_profile_picture/flutter_profile_picture.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:url_launcher/url_launcher.dart';
class NewProfile1 extends StatefulWidget {
const NewProfile1({Key? key, required this.text}) : super(key: key);
final Map<dynamic, dynamic> text;
@override
State<NewProfile1> createState() => _NewProfileState();
}
class _NewProfileState extends State<NewProfile1>
with TickerProviderStateMixin {
List<SaveInteraction> viewformData = [];
bool _isExpanded = false;
var item;
TextEditingController firstNameController = TextEditingController();
final ScrollController _scrollController = ScrollController();
late final TabController _tabController;
@override
void initState() {
super.initState();
print("pooja123");
//init();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
_tabController = TabController(length: 3, vsync: this);
});
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 3,
child: SafeArea(
child: headerview(context),
),
);
// });
}
Widget headerview(BuildContext context) {
return SafeArea(
child: Scaffold(
backgroundColor: Constants.bgcolor,
body: Stack(
children: <Widget>[
Container(
// color: Colors.blue,
child: Column(
children: <Widget>[
getAppBarUI(),
Expanded(
child: NestedScrollView(
controller: _scrollController,
headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return Column(
children: <Widget>[
buildCardView(
context,
)
],
);
}, childCount: 1),
),
SliverPersistentHeader(
pinned: true,
floating: true,
delegate: ContestTabHeader(
Container(
//color: Constants.bgcolor2,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
colors: [
Constants.tabbgColor,
Constants.k2color,
]),
),
child: TabBar(
indicatorColor: Colors.white,
labelColor: Colors
.white, // Color of the selected tab text
unselectedLabelColor: Colors.black,
// unselectedLabelColor:
// Color.fromARGB(255, 163, 159, 159),
tabs: [
// Tab(text: "Sentiment"),
Tab(
child: Text1(
title: "Details",
txtfont: 15.0,
),
),
Tab(
child: Text1(
title: "Activities",
txtfont: 15.0,
),
),
Tab(
child: Text1(
title: "Engagements",
txtfont: 15.0,
),
),
],
),
),
),
)
];
},
body: TabBarView(
//controller: _tabController,
children: [
// LocationTab(text: widget.text["id"]),
LocationK2Tab(text: widget.text["id"]),
// Activities(text: widget.text["id"]),
ActivitiesK2(text: widget.text["id"]),
EngagementTab(text: widget.text["id"]),
],
),
),
)
],
),
),
],
),
floatingActionButton: Visibility(
visible: true,
child: FloatingActionButton(
onPressed: () async {
Navigator.push(
context, MaterialPageRoute(builder: (context) => FormList()));
},
foregroundColor: Colors.white,
backgroundColor: const Color.fromARGB(255, 0, 71, 132),
child: new Icon(Icons.add),
),
),
),
);
}
buildCardView(BuildContext context) {
MediaQuery.of(context).size.height * 0.35;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Stack(
clipBehavior: Clip.none,
alignment: Alignment.center,
children: [
Container(
width:
MediaQuery.of(context).size.width, // Adjust width as needed
height: 110, // Adjust height as needed
decoration: BoxDecoration(color: Constants.k2color),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text1(
title: widget.text!["name"],
txtcolor: Colors.white,
fontweight: FontWeight.normal,
txtfont: 20.0),
Text1(
title: widget.text!["speciality"],
txtcolor: Colors.white,
fontweight: FontWeight.normal,
txtfont: 14.0),
],
),
),
Positioned(
bottom: -45,
child: Container(
child: widget.text["img_path"] == ""
? ProfilePicture(
name: widget.text!["name"],
radius: 48,
fontsize: 21,
)
: ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(48),
child: CachedNetworkImage(
imageUrl: widget.text!["img_path"],
imageBuilder: (context, imageProvider) => Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider,
fit: BoxFit.fill,
),
),
),
),
),
),
),
)
],
),
SizedBox(
height: 55.0,
),
_ProfileInfoRow(text: widget.text["id"]),
locandpnoinfo(),
const SizedBox(
height: 5.0,
),
Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text1(
title: "Profile Summary",
txtcolor: Colors.black,
fontweight: FontWeight.normal,
txtfont: 18.0),
),
),
const SizedBox(
height: 5.0,
),
Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.only(left: 15.0),
child: Text1(
title: widget.text!["summarry"],
txtcolor: Colors.black,
fontweight: FontWeight.normal,
txtfont: 14.0),
),
),
SizedBox(
height: 10.0,
),
ListTileTheme(
dense: true,
child: Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Card(
margin: EdgeInsets.all(1.0),
// elevation: 5,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0.0),
),
color: Constants.k2color11,
child: ExpansionTile(
// collapsedBackgroundColor: Color(0xFF2b9af3),
onExpansionChanged: (bool expanded) {
setState(() {
_isExpanded = expanded;
});
},
backgroundColor: Constants.k2color11,
trailing: Icon(
_isExpanded
? Icons.keyboard_arrow_up
: Icons.keyboard_arrow_down,
color: Colors.black),
title: Row(
mainAxisAlignment: MainAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
children: [
Text1(
title: "Notes",
txtcolor: Colors.black,
fontweight: FontWeight.normal,
txtfont: 17.0),
const SizedBox(
width: 8.0,
),
Text1(
title: "(0)",
txtcolor: Colors.black,
fontweight: FontWeight.normal,
txtfont: 17.0),
],
),
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8.0),
),
hintText: 'Write your note here',
contentPadding: EdgeInsets.all(16.0),
),
maxLines:
null, // Allows the TextField to expand vertically
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: OutlinedButton(
onPressed: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (_) => PublicationsData()));
},
child: Text(
'Save',
style: TextStyle(color: Constants.k2color),
),
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
),
]),
),
),
), // adds spacing between the text and image
SizedBox(
height: 10.0,
),
],
// ),
);
}
void bottomshet(affiliation_data) {
// print("Aff_index_data: ${affiliation_data}");
showModalBottomSheet<void>(
// isScrollControlled:
// true,
context: context,
useRootNavigator: true,
isScrollControlled: false,
enableDrag: true,
useSafeArea: true,
constraints: const BoxConstraints(
maxWidth: double.infinity,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(0),
),
),
clipBehavior: Clip.antiAliasWithSaveLayer,
// sheetAnimationStyle: _animationStyle,
builder: (BuildContext context) {
return
// makeDismissible(
// child:
DraggableScrollableSheet(
expand: false,
builder: (BuildContext context, ScrollController scrollController) {
return Container(
width: MediaQuery.of(context).size.width,
//color: Colors.white,
color: Color.fromARGB(255, 246, 248, 252),
child: Column(
children: [
Expanded(
child: ListView.builder(
controller: scrollController,
itemCount: 1,
itemBuilder: (BuildContext context, int index) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 18.0,
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.all(18.0),
child: Text(
affiliation_data['org_name'],
softWrap: true,
maxLines: 4,
style: TextStyle(
fontSize: 18.0,
color: Colors.grey[700]),
),
),
),
],
),
const SizedBox(
height: 18.0,
),
Divider(),
const SizedBox(
height: 8.0,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
padding: EdgeInsets.only(left: 18.0),
child: Text(
"Department",
style: TextStyle(fontSize: 13.0),
),
),
Padding(
padding: const EdgeInsets.only(left: 18.0),
child: Text(
affiliation_data['dept'],
style: TextStyle(
fontSize: 14.0,
color: Colors.grey[700]),
),
)
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
padding:
EdgeInsets.only(left: 18.0, top: 18.0),
child: Text(
"Role",
style: TextStyle(fontSize: 13.0),
),
),
Padding(
padding: const EdgeInsets.only(left: 18.0),
child: Text(
affiliation_data['role'],
style: TextStyle(
fontSize: 14.0,
color: Colors.grey[700]),
),
)
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(
left: 18.0, top: 18.0),
child: Text(
"Time Frame".toString(),
style: TextStyle(fontSize: 13.0),
),
),
Padding(
padding: const EdgeInsets.only(left: 18.0),
child: Text(
affiliation_data['time_frame'],
style: TextStyle(
fontSize: 14.0,
color: Colors.grey[700]),
),
)
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
padding:
EdgeInsets.only(left: 18.0, top: 18.0),
child: Text(
"Oraganization Type",
style: TextStyle(fontSize: 13.0),
),
),
Padding(
padding: const EdgeInsets.only(left: 18.0),
child: Text(
affiliation_data['org_type'],
style: TextStyle(
fontSize: 14.0,
color: Colors.grey[700]),
),
)
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
padding:
EdgeInsets.only(left: 18.0, top: 18.0),
child: Text(
"Eng Type",
style: TextStyle(fontSize: 13.0),
),
),
Padding(
padding: const EdgeInsets.only(left: 18.0),
child: Text(
affiliation_data['emg_type'],
style: TextStyle(
fontSize: 14.0,
color: Colors.grey[700]),
),
)
],
),
],
);
},
),
),
],
),
);
},
);
//);
},
);
}
Widget getAppBarUI() {
return Container(
decoration: BoxDecoration(
color: Constants.k2color,
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.grey.withOpacity(0.2),
offset: const Offset(0, 2),
blurRadius: 8.0),
],
),
child: Padding(
padding: EdgeInsets.only(top: 2, left: 8, right: 8),
child: Row(
children: <Widget>[
Container(
alignment: Alignment.topLeft,
// width: AppBar().preferredSize.height,
// height: AppBar().preferredSize.height,
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: const BorderRadius.all(
Radius.circular(32.0),
),
onTap: () {
Navigator.pop(context);
},
child: const Padding(
padding: EdgeInsets.all(8.0),
child: Row(
children: [
Icon(
Icons.arrow_back_ios_new,
size: 18,
color: Colors.white,
),
SizedBox(
width: 8,
),
Text(
"Contacts",
style: TextStyle(fontSize: 14.0, color: Colors.white),
)
],
),
),
),
),
),
const Expanded(
child: Text(
"",
maxLines: 1,
softWrap: true,
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 14,
overflow: TextOverflow.ellipsis,
),
),
),
],
),
),
);
}
locandpnoinfo() {
return Column(
children: [
const SizedBox(
height: 8.0,
),
_buildClickableRow(
icon: Icons.location_city_sharp,
text: widget.text["addr"] ?? "Azienda Ospedaliera di Padova",
),
const SizedBox(
height: 8.0,
),
_buildClickableRow(
icon: Icons.location_pin,
text: widget.text?["Country"] ??
"Via Giustiniani, 2, Padova, Veneto 35128, Italy",
onTap: _openMapsByAddress,
),
const SizedBox(
height: 8.0,
),
_buildClickableRow(
icon: Icons.email,
text: widget.text?["email"],
onTap: () async {
await emailSend(widget.text?["email"]);
},
),
SizedBox(
height: 8.0,
),
_buildClickableRow(
icon: Icons.phone,
text: widget.text!["phone_no"].toString(),
onTap: () async {
await callinfo(widget.text?["phone_no"].toString());
},
),
],
);
}
Future<void> _openMapsByAddress() async {
final address = 'Italy';
final Uri mapsUri = Uri(
scheme: 'https',
host: 'www.google.com',
path: 'maps/search/',
query: address,
);
if (!await launchUrl(mapsUri)) {
throw 'Could not launch $mapsUri';
}
}
Future<void> emailSend(email) async {
String? encodeQueryParameters(Map<String, String> params) {
return params.entries
.map((MapEntry<String, String> entry) =>
Uri.encodeComponent(entry.key) +
'=' +
Uri.encodeComponent(entry.value))
.join('&');
}
final Uri emailLaunchUri = Uri(
scheme: 'mailto',
path: email,
query: encodeQueryParameters(<String, String>{
'subject': 'Example Subject',
'body': 'Hello, this is a sample body text.',
}),
);
if (await launchUrl(emailLaunchUri)) {
launchUrl(emailLaunchUri);
} else {
throw 'Could not launch $emailLaunchUri';
}
}
Future<void> callinfo(pno) async {
final call = Uri.parse('tel:$pno');
if (await canLaunchUrl(call)) {
launchUrl(call);
} else {
throw 'Could not launch $call';
}
}
}
dispalytext(dispalydata) {
return Text1(
title: dispalydata,
txtcolor: Colors.black,
fontweight: FontWeight.normal,
txtfont: 14.0);
}
getIcon(IconData icons) {
return Icon(
icons,
color: Color.fromARGB(255, 0, 71, 132),
);
}
Widget _buildClickableRow({
required IconData icon,
required String text,
VoidCallback? onTap,
}) {
return Padding(
padding: const EdgeInsets.only(left: 8.0),
child: InkWell(
onTap: onTap,
child: Row(
children: [
getIcon(icon),
const SizedBox(width: 3.0),
Expanded(child: dispalytext(text)),
],
),
),
);
}
class _ProfileInfoRow extends StatelessWidget {
// _ProfileInfoRow({Key? key}) : super(key: key);
final int text;
_ProfileInfoRow({required this.text, Key? key}) : super(key: key);
final List<ProfileInfoItem> _items = const [
ProfileInfoItem("Publication(s)", 688),
ProfileInfoItem("Event(s)", 111),
ProfileInfoItem("Trial(s)", 10),
];
@override
Widget build(BuildContext context) {
return Container(
height: 80,
constraints: const BoxConstraints(maxWidth: 400),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: _items
.map((item) => Expanded(
child: Row(
children: [
if (_items.indexOf(item) != 0) const VerticalDivider(),
Expanded(child: _singleItem(context, item)),
],
)))
.toList(),
),
);
}
Widget _singleItem(BuildContext context, item) => Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
item.value.toString(),
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
),
),
),
Text(
item.title,
// style: const TextStyle(
// fontWeight: FontWeight.normal,
// fontSize: 18,
// ),
// style: Theme.of(context).textTheme.caption,
)
],
);
}
class ProfileInfoItem {
final String title;
final int value;
const ProfileInfoItem(this.title, this.value);
}
class ContestTabHeader extends SliverPersistentHeaderDelegate {
ContestTabHeader(
this.searchUI,
);
final Widget searchUI;
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return Container(color: Colors.white, child: searchUI);
}
@override
double get maxExtent => 52.0;
@override
double get minExtent => 52.0;
@override
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {
return true;
}
}