Created
February 23, 2021 09:36
-
-
Save ologunB/0e1c350b6870cbec688f0d2e71e0478e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter_appmhuhyu/constants/styles.dart'; | |
import 'package:flutter_appmhuhyu/router.dart'; | |
import 'package:flutter_appmhuhyu/ui/views/home/personal/personal_chat_profile.dart'; | |
import 'package:flutter_appmhuhyu/ui/widgets/add_file_item.dart'; | |
import 'package:flutter_appmhuhyu/ui/widgets/back_button.dart'; | |
import 'package:flutter_appmhuhyu/ui/widgets/bubble_normal.dart'; | |
import 'package:flutter_appmhuhyu/ui/widgets/custom_text_widget.dart'; | |
import 'package:flutter_appmhuhyu/ui/widgets/network_image.dart'; | |
import 'package:flutter_appmhuhyu/utils/spacing.dart'; | |
import 'package:google_fonts/google_fonts.dart'; | |
import 'package:keyboard_attachable/keyboard_attachable.dart'; | |
class PersonalChatDetailScreen extends StatefulWidget { | |
@override | |
_PersonalChatDetailScreenState createState() => _PersonalChatDetailScreenState(); | |
} | |
class _PersonalChatDetailScreenState extends State<PersonalChatDetailScreen> { | |
TextEditingController textController = TextEditingController(); | |
ScrollController _scrollController = new ScrollController(); | |
String text = "LogoName"; | |
@override | |
void initState() { | |
// _scrollController.jumpTo(_scrollController.position.maxScrollExtent); | |
_scrollController.addListener(() { | |
if (_scrollController.position.pixels > MediaQuery.of(context).size.height) { | |
setState(() { | |
text = "NameofPerson"; | |
}); | |
} else { | |
text = "LogoName"; | |
setState(() {}); | |
} | |
}); | |
super.initState(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
backgroundColor: Styles.colorWhite, | |
appBar: AppBar( | |
centerTitle: true, | |
elevation: 1, | |
leading: BackButtonWidget(), | |
titleSpacing: 0, | |
actions: [ | |
Icon( | |
Icons.info, | |
color: Styles.colorGreyDark, | |
), | |
horizontalSpaceSmall | |
], | |
title: GestureDetector( | |
onTap: () { | |
routeTo(context, PersonalChatProfile()); | |
}, | |
child: Row( | |
children: [ | |
CachedImage(size: 45, imageUrl: "s"), | |
horizontalSpaceSmall, | |
horizontalSpaceTiny, | |
Expanded( | |
child: Column( | |
mainAxisSize: MainAxisSize.min, | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
CustomText(text: "John Stone", fontSize: 20, fontWeight: FontWeight.w600), | |
CustomText( | |
text: "Online", | |
fontSize: 12, | |
color: Styles.colorGreyDark, | |
), | |
], | |
), | |
), | |
], | |
), | |
), | |
), | |
body: FooterLayout( | |
child: ListView( | |
children: [ | |
Container( | |
color: Styles.colorGreyDark.withOpacity(.1), | |
child: ListView.builder( | |
itemCount: 14, | |
shrinkWrap: true, | |
controller: _scrollController, | |
physics: ClampingScrollPhysics(), | |
itemBuilder: (context, index) { | |
return BubbleNormal( | |
text: | |
'Oh yeah, I got those yesterday. Already started working on the project. Hope we can have a meeting today', | |
isSender: index % 2 == 0 ? false : true, | |
// delivered: index % 2 == 0 ? false : true, | |
seen: true, | |
); | |
})), | |
], | |
), | |
footer: Container( | |
color: Styles.colorGreyDark.withOpacity(.1), | |
padding: EdgeInsets.symmetric(vertical: 3, horizontal: 15), | |
child: SafeArea( | |
child: Row( | |
children: [ | |
Expanded( | |
child: Container( | |
padding: EdgeInsets.symmetric(horizontal: 14), | |
decoration: BoxDecoration( | |
borderRadius: BorderRadius.circular(30.0), | |
color: Styles.colorWhite, | |
border: Border.all( | |
color: MediaQuery.of(context).viewInsets.bottom == 0.0 | |
? Styles.colorWhite | |
: Styles.appCanvasGreen)), | |
child: Row( | |
children: [ | |
textController.text.isEmpty | |
? Icon( | |
Icons.emoji_emotions_outlined, | |
color: Styles.colorGreyDark, | |
) | |
: SizedBox(), | |
horizontalSpaceTiny, | |
Expanded( | |
child: TextFormField( | |
keyboardType: TextInputType.text, | |
controller: textController, | |
textInputAction: TextInputAction.go, | |
maxLines: 1, | |
cursorColor: Styles.appCanvasGreen, | |
style: GoogleFonts.nunito(color: Styles.colorBlack, fontSize: 16), | |
onChanged: (a) { | |
setState(() {}); | |
}, | |
onTap: () { | |
_scrollController.animateTo(_scrollController.position.maxScrollExtent, | |
curve: Curves.easeOut, duration: const Duration(milliseconds: 300)); | |
}, | |
decoration: InputDecoration( | |
hintStyle: GoogleFonts.nunito( | |
color: Styles.colorGreyDark, | |
fontWeight: FontWeight.w400, | |
fontSize: 16), | |
labelStyle: GoogleFonts.nunito( | |
color: Styles.colorGreyDark, | |
fontWeight: FontWeight.w400, | |
fontSize: 16), | |
hintText: "Type your Message...", | |
focusedBorder: InputBorder.none, | |
enabledBorder: InputBorder.none, | |
border: InputBorder.none, | |
), | |
), | |
), | |
horizontalSpaceTiny, | |
InkWell( | |
onTap: () { | |
showAddFile(context); | |
}, | |
child: Transform.rotate( | |
angle: 150, | |
child: Icon( | |
Icons.attach_file, | |
color: Styles.colorGreyDark, | |
), | |
), | |
), | |
], | |
), | |
)), | |
Container( | |
height: 42, | |
width: 42, | |
margin: EdgeInsets.all(6), | |
decoration: BoxDecoration( | |
borderRadius: BorderRadius.circular(21), color: Styles.appCanvasGreen), | |
child: textController.text.isEmpty | |
? Icon( | |
Icons.mic, | |
color: Styles.colorWhite, | |
) | |
: GestureDetector( | |
onTap: () { | |
_scrollController.animateTo(_scrollController.position.maxScrollExtent, | |
curve: Curves.easeOut, duration: const Duration(milliseconds: 300)); | |
textController.clear(); | |
setState(() {}); | |
}, | |
child: Transform.rotate( | |
angle: 100, child: Icon(Icons.send, color: Styles.colorWhite)), | |
), | |
) | |
], | |
), | |
), | |
), | |
), | |
); | |
} | |
void showAddFile(BuildContext context) { | |
showModalBottomSheet( | |
isScrollControlled: true, | |
context: context, | |
shape: RoundedRectangleBorder( | |
borderRadius: BorderRadius.circular(30), | |
), | |
builder: (context) { | |
return Container( | |
padding: EdgeInsets.all(10), | |
child: Column( | |
mainAxisSize: MainAxisSize.min, | |
children: [ | |
verticalSpaceSmall, | |
Container( | |
height: 6, | |
width: 50, | |
decoration: BoxDecoration( | |
borderRadius: BorderRadius.circular(10), color: Styles.colorGreyDark), | |
), | |
verticalSpaceMedium, | |
AddFileItem(text: "Camera", icon: Icons.camera_alt), | |
AddFileItem(text: "Photo and Video", icon: Icons.image), | |
AddFileItem(text: "Contact", icon: Icons.person), | |
AddFileItem(text: "Document", icon: Icons.insert_drive_file), | |
AddFileItem(text: "Location", icon: Icons.location_on), | |
verticalSpaceMedium, | |
], | |
), | |
); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment