Skip to content

Instantly share code, notes, and snippets.

@davidmigloz
Created December 15, 2023 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidmigloz/a30484f202a07f42b3be6e384c2d93b3 to your computer and use it in GitHub Desktop.
Save davidmigloz/a30484f202a07f42b3be6e384c2d93b3 to your computer and use it in GitHub Desktop.
Generated code from pixels2flutter.dev
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
useMaterial3: true,
primarySwatch: Colors.blue,
),
home: ChatScreen(),
);
}
}
class ChatScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: BackButton(),
title: Row(
children: [
CircleAvatar(
backgroundImage: NetworkImage('https://placehold.co/40x40?description=Profile%20image%20of%20Tyler%20Benil'),
),
SizedBox(width: 8),
Text('Tyler Benil'),
],
),
actions: [
IconButton(
icon: Icon(Icons.videocam),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.call),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.more_vert),
onPressed: () {},
),
],
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Expanded(
child: ListView(
children: [
ChatBubble(
text: "I'm in a meeting at the moment.\nWon't take more than 20 min.",
time: "11:45",
isSender: false,
),
ChatBubble(
text: "I’ll Wait near the Skyler coffee shop",
time: "11:50",
isSender: true,
),
ChatBubble(
text: "Try their hazelnut Mocha. It's the best.",
time: "12:00",
isSender: false,
),
ChatBubble(
text: "It's 12:20. I’m leaving.",
time: "12:20",
isSender: true,
),
ChatBubble(
text: "Rachel gave me some paperwork.\nGive me 5 more minutes. Please.",
time: "12:25",
isSender: false,
),
ChatBubble(
text: "You deleted this message.",
time: "12:28",
isSender: true,
isDeleted: true,
),
ChatBubble(
text: "Hey, I’m here. where are you?",
time: "12:25",
isSender: false,
),
ChatBubble(
text: "I’m near the piano wearing red.",
time: "12:30",
isSender: true,
),
],
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 8.0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(25.0),
),
child: Row(
children: [
IconButton(
icon: Icon(Icons.mic, color: Colors.blue),
onPressed: () {},
),
Expanded(
child: TextField(
decoration: InputDecoration(
hintText: "Type a message",
border: InputBorder.none,
),
),
),
IconButton(
icon: Icon(Icons.send, color: Colors.blue),
onPressed: () {},
),
],
),
),
],
),
),
);
}
}
class ChatBubble extends StatelessWidget {
final String text;
final String time;
final bool isSender;
final bool isDeleted;
const ChatBubble({
Key? key,
required this.text,
required this.time,
this.isSender = false,
this.isDeleted = false,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Align(
alignment: isSender ? Alignment.centerRight : Alignment.centerLeft,
child: Container(
margin: EdgeInsets.symmetric(vertical: 4.0),
padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
decoration: BoxDecoration(
color: isSender ? Colors.blue[100] : Colors.grey[200],
borderRadius: BorderRadius.circular(16.0),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
text,
style: TextStyle(
color: isDeleted ? Colors.grey : Colors.black,
fontSize: 16.0,
),
),
SizedBox(height: 4.0),
Text(
time,
style: TextStyle(
color: Colors.grey,
fontSize: 12.0,
),
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment