Created
November 14, 2024 21:14
-
-
Save davidmigloz/8cbb802ce9b5c90771a58907f7a21e19 to your computer and use it in GitHub Desktop.
Generated code from pixels2flutter.dev
This file contains hidden or 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'; | |
void main() { | |
runApp(const ChatApp()); | |
} | |
class ChatApp extends StatelessWidget { | |
const ChatApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue), | |
useMaterial3: true, | |
), | |
home: const ChatScreen(), | |
); | |
} | |
} | |
class ChatScreen extends StatelessWidget { | |
const ChatScreen({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
backgroundColor: Colors.blue, | |
title: Row( | |
children: [ | |
CircleAvatar( | |
backgroundImage: NetworkImage( | |
'https://placehold.co/40x40?description=Profile%20picture', | |
), | |
), | |
const SizedBox(width: 10), | |
const Text( | |
'Tyler Benil', | |
style: TextStyle(color: Colors.white), | |
), | |
], | |
), | |
actions: [ | |
IconButton( | |
icon: const Icon(Icons.videocam, color: Colors.white), | |
onPressed: () {}, | |
), | |
IconButton( | |
icon: const Icon(Icons.call, color: Colors.white), | |
onPressed: () {}, | |
), | |
IconButton( | |
icon: const Icon(Icons.more_vert, color: Colors.white), | |
onPressed: () {}, | |
), | |
], | |
), | |
body: Container( | |
color: const Color(0xFFF5F7FA), | |
child: ListView( | |
padding: const EdgeInsets.all(16), | |
children: [ | |
_buildReceivedMessage( | |
'I\'m in a meeting at the moment. Won\'t take more than 20 min.', | |
'11:45', | |
), | |
_buildSentMessage( | |
'I’ll Wait near the Skyler coffee shop', | |
'11:50', | |
), | |
_buildReceivedMessage( | |
'Try their hazelnut Mocha. It\'s the best.', | |
'12:00', | |
), | |
_buildSentMessage( | |
'It\'s 12:20. I’m leaving.', | |
'12:20', | |
), | |
_buildReceivedMessage( | |
'Rachel gave me some paperwork. Give me 5 more minutes. Please.', | |
'12:25', | |
), | |
_buildDeletedMessage( | |
'You deleted this message.', | |
'12:28', | |
), | |
_buildReceivedMessage( | |
'Hey, I’m here. where are you?', | |
'12:25', | |
), | |
_buildSentMessage( | |
'I’m near the piano wearing red.', | |
'12:30', | |
), | |
], | |
), | |
), | |
); | |
} | |
Widget _buildReceivedMessage(String text, String time) { | |
return Align( | |
alignment: Alignment.centerLeft, | |
child: Container( | |
margin: const EdgeInsets.symmetric(vertical: 5), | |
padding: const EdgeInsets.all(12), | |
decoration: BoxDecoration( | |
color: Colors.grey.shade200, | |
borderRadius: BorderRadius.circular(8), | |
), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Text( | |
text, | |
style: const TextStyle(color: Colors.black87), | |
), | |
const SizedBox(height: 5), | |
Text( | |
time, | |
style: const TextStyle(color: Colors.black54, fontSize: 12), | |
), | |
], | |
), | |
), | |
); | |
} | |
Widget _buildSentMessage(String text, String time) { | |
return Align( | |
alignment: Alignment.centerRight, | |
child: Container( | |
margin: const EdgeInsets.symmetric(vertical: 5), | |
padding: const EdgeInsets.all(12), | |
decoration: BoxDecoration( | |
color: Colors.blue.shade100, | |
borderRadius: BorderRadius.circular(8), | |
), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.end, | |
children: [ | |
Text( | |
text, | |
style: const TextStyle(color: Colors.black87), | |
), | |
const SizedBox(height: 5), | |
Text( | |
time, | |
style: const TextStyle(color: Colors.black54, fontSize: 12), | |
), | |
], | |
), | |
), | |
); | |
} | |
Widget _buildDeletedMessage(String text, String time) { | |
return Align( | |
alignment: Alignment.centerLeft, | |
child: Container( | |
margin: const EdgeInsets.symmetric(vertical: 5), | |
padding: const EdgeInsets.all(12), | |
decoration: BoxDecoration( | |
color: Colors.grey.shade300, | |
borderRadius: BorderRadius.circular(8), | |
), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Row( | |
children: [ | |
const Icon(Icons.block, size: 16, color: Colors.black54), | |
const SizedBox(width: 5), | |
Text( | |
text, | |
style: const TextStyle(color: Colors.black54), | |
), | |
], | |
), | |
const SizedBox(height: 5), | |
Text( | |
time, | |
style: const TextStyle(color: Colors.black54, fontSize: 12), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment