2024-09-13 00:51:36 +04:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'comment_model.dart';
|
2024-09-13 01:19:44 +04:00
|
|
|
import 'user_model.dart';
|
2024-09-13 00:51:36 +04:00
|
|
|
|
|
|
|
class CommentsWidget extends StatelessWidget {
|
|
|
|
const CommentsWidget({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final data = [
|
|
|
|
CommentModel(
|
|
|
|
title: 'Oh my god',
|
|
|
|
text: 'this app is so cool ' * 10,
|
2024-09-13 01:19:44 +04:00
|
|
|
user: UserModel(
|
|
|
|
nickname: 'Steve',
|
|
|
|
avatarUrl:
|
|
|
|
'https://preview.free3d.com/img/2016/03/1875481443430303321/hld8c0oa.jpg',
|
|
|
|
),
|
2024-09-13 00:51:36 +04:00
|
|
|
),
|
|
|
|
CommentModel(
|
|
|
|
title: 'Listen to me',
|
|
|
|
text: 'This app is like Half-Life 3 - it will never be released',
|
2024-09-13 01:19:44 +04:00
|
|
|
user: UserModel(
|
|
|
|
nickname: 'G-Man',
|
|
|
|
avatarUrl:
|
|
|
|
'https://us-tuna-sounds-images.voicemod.net/356aeabd-18d5-40d8-af31-b479f4eff183-1704672174928.png',
|
|
|
|
),
|
2024-09-13 00:51:36 +04:00
|
|
|
),
|
|
|
|
CommentModel(
|
|
|
|
title: 'BREAKING!!!',
|
|
|
|
text: 'The next lab work will have DLC in the form of likes',
|
2024-09-13 01:19:44 +04:00
|
|
|
user: UserModel(
|
|
|
|
nickname: 'Bethesda',
|
|
|
|
avatarUrl: 'https://i.playground.ru/p/BWixorSTeZQfoPvdVL9lgA.jpeg',
|
|
|
|
),
|
2024-09-13 00:51:36 +04:00
|
|
|
),
|
|
|
|
CommentModel(
|
|
|
|
title: 'Test',
|
|
|
|
text: 'Test',
|
2024-09-13 01:19:44 +04:00
|
|
|
user: UserModel(
|
|
|
|
nickname: 'Noname',
|
|
|
|
),
|
2024-09-13 00:51:36 +04:00
|
|
|
),
|
|
|
|
CommentModel(
|
|
|
|
title: 'Test',
|
|
|
|
text: 'Test',
|
2024-09-13 01:19:44 +04:00
|
|
|
user: UserModel(
|
|
|
|
nickname: 'Noname',
|
|
|
|
),
|
2024-09-13 00:51:36 +04:00
|
|
|
),
|
|
|
|
];
|
|
|
|
|
|
|
|
return SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: data.map((e) => _Comment.fromData(e)).toList(),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _Comment extends StatelessWidget {
|
|
|
|
final String title;
|
|
|
|
final String text;
|
2024-09-13 01:19:44 +04:00
|
|
|
final UserModel? user;
|
2024-09-13 00:51:36 +04:00
|
|
|
|
|
|
|
const _Comment({
|
|
|
|
required this.title,
|
|
|
|
required this.text,
|
2024-09-13 01:19:44 +04:00
|
|
|
this.user,
|
2024-09-13 00:51:36 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
factory _Comment.fromData(CommentModel model) => _Comment(
|
2024-09-13 01:19:44 +04:00
|
|
|
title: model.title,
|
|
|
|
text: model.text,
|
|
|
|
user: model.user,
|
|
|
|
);
|
2024-09-13 00:51:36 +04:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
margin: const EdgeInsets.all(16),
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.white70,
|
|
|
|
borderRadius: BorderRadius.circular(16),
|
|
|
|
border: Border.all(color: Colors.grey),
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Colors.grey.withOpacity(.5),
|
|
|
|
spreadRadius: 4,
|
|
|
|
offset: const Offset(0, 5),
|
|
|
|
blurRadius: 8,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2024-09-13 01:19:44 +04:00
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(30),
|
|
|
|
child: SizedBox(
|
|
|
|
height: 80,
|
|
|
|
width: 80,
|
|
|
|
child: Image.network(
|
|
|
|
user!.avatarUrl != null && user!.avatarUrl!.isNotEmpty
|
|
|
|
? user!.avatarUrl!
|
|
|
|
: '',
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
errorBuilder: (_, __, ___) => const Placeholder(),
|
|
|
|
),
|
|
|
|
),
|
2024-09-13 00:51:36 +04:00
|
|
|
),
|
2024-09-13 01:19:44 +04:00
|
|
|
const SizedBox(height: 8),
|
|
|
|
Text(
|
|
|
|
user!.nickname,
|
|
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
|
|
),
|
|
|
|
],
|
2024-09-13 00:51:36 +04:00
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 16.0),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
title,
|
2024-09-13 01:19:44 +04:00
|
|
|
style: Theme.of(context).textTheme.headlineSmall,
|
2024-09-13 00:51:36 +04:00
|
|
|
),
|
2024-09-13 01:19:44 +04:00
|
|
|
const SizedBox(height: 8),
|
2024-09-13 00:51:36 +04:00
|
|
|
Text(
|
|
|
|
text,
|
|
|
|
style: Theme.of(context).textTheme.bodyLarge,
|
2024-09-13 01:19:44 +04:00
|
|
|
),
|
2024-09-13 00:51:36 +04:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|