Advertisement
darmariduan

message1.dart

Jun 24th, 2022
1,135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 7.38 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:google_fonts/google_fonts.dart';
  3. import 'package:tugas_flutter/main_page.dart';
  4.  
  5. class Message1 extends StatelessWidget {
  6.   @override
  7.   Widget build(BuildContext context) {
  8.     Widget receiverBubble({
  9.       required imageUrl,
  10.       required String text,
  11.       required time,
  12.     }) {
  13.       return Container(
  14.         margin: EdgeInsets.only(
  15.           bottom: 30,
  16.         ),
  17.         child: Row(
  18.           crossAxisAlignment: CrossAxisAlignment.end,
  19.           children: [
  20.             Image.asset(
  21.               imageUrl,
  22.               width: 40,
  23.             ),
  24.             SizedBox(
  25.               width: 12,
  26.             ),
  27.             Container(
  28.               padding: EdgeInsets.symmetric(
  29.                 horizontal: 20,
  30.                 vertical: 12,
  31.               ),
  32.               decoration: BoxDecoration(
  33.                 color: Color(0xffEBEFF3),
  34.                 borderRadius: BorderRadius.only(
  35.                   topRight: Radius.circular(20),
  36.                   topLeft: Radius.circular(20),
  37.                   bottomRight: Radius.circular(20),
  38.                 ),
  39.               ),
  40.               child: Column(
  41.                 crossAxisAlignment: CrossAxisAlignment.start,
  42.                 children: [
  43.                   Text(
  44.                     text,
  45.                     style: GoogleFonts.poppins(
  46.                       fontSize: 16,
  47.                       color: Color(0xff505C6B),
  48.                     ),
  49.                   ),
  50.                   SizedBox(
  51.                     height: 5,
  52.                   ),
  53.                   Text(
  54.                     time,
  55.                     style: GoogleFonts.poppins(
  56.                       fontWeight: FontWeight.w300,
  57.                       color: Color(0xff505C6B),
  58.                     ),
  59.                   ),
  60.                 ],
  61.               ),
  62.             ),
  63.           ],
  64.         ),
  65.       );
  66.     }
  67.  
  68.     Widget senderBubble({
  69.       required String imageUrl,
  70.       required String text,
  71.       required String time,
  72.     }) {
  73.       return Container(
  74.         margin: EdgeInsets.only(
  75.           bottom: 30,
  76.         ),
  77.         child: Row(
  78.           mainAxisAlignment: MainAxisAlignment.end,
  79.           crossAxisAlignment: CrossAxisAlignment.end,
  80.           children: [
  81.             Container(
  82.               padding: EdgeInsets.symmetric(
  83.                 horizontal: 20,
  84.                 vertical: 12,
  85.               ),
  86.               decoration: BoxDecoration(
  87.                 color: Color(0xffFFFFFF),
  88.                 borderRadius: BorderRadius.only(
  89.                   topRight: Radius.circular(20),
  90.                   topLeft: Radius.circular(20),
  91.                   bottomRight: Radius.circular(20),
  92.                 ),
  93.               ),
  94.               child: Column(
  95.                 crossAxisAlignment: CrossAxisAlignment.end,
  96.                 children: [
  97.                   Text(
  98.                     text,
  99.                     style: GoogleFonts.poppins(
  100.                       fontSize: 16,
  101.                       color: Color(0xff505C6B),
  102.                     ),
  103.                   ),
  104.                   SizedBox(
  105.                     height: 5,
  106.                   ),
  107.                   Text(
  108.                     time,
  109.                     style: GoogleFonts.poppins(
  110.                       fontWeight: FontWeight.w300,
  111.                       color: Color(0xff505C6B),
  112.                     ),
  113.                   ),
  114.                 ],
  115.               ),
  116.             ),
  117.             SizedBox(
  118.               width: 12,
  119.             ),
  120.             Image.asset(
  121.               imageUrl,
  122.               width: 40,
  123.             ),
  124.           ],
  125.         ),
  126.       );
  127.     }
  128.  
  129.     Widget header() {
  130.       return Container(
  131.         width: double.infinity,
  132.         height: 115,
  133.         padding: EdgeInsets.all(30),
  134.         decoration: BoxDecoration(
  135.           color: Color(0xffFFFFFF),
  136.           borderRadius: BorderRadius.vertical(
  137.             bottom: Radius.circular(30),
  138.           ),
  139.         ),
  140.         child: Row(
  141.           children: [
  142.             Image.asset(
  143.               'images/dokter1.png',
  144.               width: 55,
  145.             ),
  146.             SizedBox(
  147.               width: 12,
  148.             ),
  149.             Column(
  150.               crossAxisAlignment: CrossAxisAlignment.start,
  151.               children: [
  152.                 Text(
  153.                   'Jonathan Tesla',
  154.                   style: GoogleFonts.poppins(
  155.                     color: Color(0xff2C3A59),
  156.                     fontSize: 16,
  157.                     fontWeight: FontWeight.w500,
  158.                   ),
  159.                 ),
  160.                 SizedBox(
  161.                   height: 2,
  162.                 ),
  163.                 Text(
  164.                   'Dentist Spesialist',
  165.                   style: GoogleFonts.poppins(
  166.                     fontWeight: FontWeight.w300,
  167.                     color: Color(0xff808BA2),
  168.                   ),
  169.                 ),
  170.               ],
  171.             ),
  172.             Spacer(),
  173.             TextButton(
  174.               onPressed: () {
  175.                 Navigator.pop(context);
  176.               },
  177.               child: Icon(
  178.                 Icons.arrow_back,
  179.                 color: Colors.grey,
  180.               ),
  181.             ),
  182.           ],
  183.         ),
  184.       );
  185.     }
  186.  
  187.     Widget body() {
  188.       return Expanded(
  189.         child: Padding(
  190.           padding: EdgeInsets.symmetric(
  191.             horizontal: 30,
  192.           ),
  193.           child: Column(
  194.             children: [
  195.               SizedBox(
  196.                 height: 30,
  197.               ),
  198.               senderBubble(
  199.                 imageUrl: 'images/client.png',
  200.                 text: 'Hallo Dok',
  201.                 time: '22:08',
  202.               ),
  203.               receiverBubble(
  204.                 imageUrl: 'images/dokter1.png',
  205.                 text: 'Ada yang bisa saya bantu?',
  206.                 time: '22:10',
  207.               ),
  208.               senderBubble(
  209.                 imageUrl: 'images/client.png',
  210.                 text: 'Kenapa RRQ Kalah dok?',
  211.                 time: '22:11',
  212.               ),
  213.               receiverBubble(
  214.                 imageUrl: 'images/dokter1.png',
  215.                 text: 'pertanyaan yang sulit untuk saya jawab',
  216.                 time: '22:12',
  217.               ),
  218.             ],
  219.           ),
  220.         ),
  221.       );
  222.     }
  223.  
  224.     Widget chatInput() {
  225.       return Container(
  226.         width: MediaQuery.of(context).size.width - (2 * 30),
  227.         padding: EdgeInsets.all(16),
  228.         decoration: BoxDecoration(
  229.           color: Color(0xffFFFFFF),
  230.           borderRadius: BorderRadius.circular(75),
  231.         ),
  232.         child: Row(
  233.           mainAxisAlignment: MainAxisAlignment.spaceBetween,
  234.           children: [
  235.             Text(
  236.               'Ketik Pesan ...',
  237.               style: GoogleFonts.poppins(
  238.                 fontWeight: FontWeight.w300,
  239.                 fontSize: 16,
  240.                 color: Color(0xff999999),
  241.               ),
  242.             ),
  243.             Icon(
  244.               Icons.send,
  245.               color: Colors.blue,
  246.             ),
  247.           ],
  248.         ),
  249.       );
  250.     }
  251.  
  252.     return Scaffold(
  253.       backgroundColor: Color(0xffF8FAFC),
  254.       floatingActionButton: chatInput(),
  255.       floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
  256.       body: SafeArea(
  257.         child: Column(
  258.           children: [
  259.             header(),
  260.             body(),
  261.           ],
  262.         ),
  263.       ),
  264.     );
  265.   }
  266. }
  267.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement