PIbd-31_MasenkinMS_PMU/lib/view/details_page/details_page.dart

87 lines
2.6 KiB
Dart
Raw Normal View History

2024-09-30 02:09:26 +04:00
import 'package:flutter/material.dart';
import 'package:pmu_labworks/domain/models/comment.dart';
class DetailsPage extends StatelessWidget {
final CommentModel model;
const DetailsPage(this.model, {super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
2024-09-30 18:24:51 +04:00
title: Text(
'${_shortenNickname(model.user.nickname)}\'s comment',
),
2024-09-30 02:09:26 +04:00
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Stack(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: model.user.avatarUrl != null
? Image.network(
model.user.avatarUrl!,
height: 150,
width: 150,
fit: BoxFit.cover,
)
: Container(
height: 150,
width: 150,
color: Colors.grey,
child: const Icon(Icons.person, size: 50),
),
),
Positioned(
left: 8,
bottom: 8,
child: Container(
padding: const EdgeInsets.symmetric(
vertical: 4.0, horizontal: 8.0),
color: Colors.black.withOpacity(0.6),
child: Text(
2024-09-30 18:24:51 +04:00
_shortenNickname(model.user.nickname, maxLength: 13),
2024-09-30 02:09:26 +04:00
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
),
],
),
const SizedBox(height: 24),
Text(
model.title,
style: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16),
Text(
model.text,
style: const TextStyle(
fontSize: 16,
),
),
],
),
),
);
}
2024-09-30 18:24:51 +04:00
String _shortenNickname(String nickname, {int maxLength = 15}) {
if (nickname.length > maxLength) {
return nickname.substring(0, maxLength) + '...';
}
return nickname;
}
2024-09-30 02:09:26 +04:00
}