PIbd-31_MasenkinMS_PMU/lib/view/details_page/details_page.dart
2024-10-02 02:39:17 +04:00

87 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:pmu_labworks/components/extensions/context_x.dart';
import 'package:pmu_labworks/domain/models/comment.dart';
class DetailsPage extends StatelessWidget {
final CommentData model;
const DetailsPage(this.model, {super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
context.locale.comment(model.user.nickname),
),
),
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(
_shortenNickname(model.user.nickname, maxLength: 13),
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,
),
),
],
),
),
);
}
String _shortenNickname(String nickname, {int maxLength = 15}) {
if (nickname.length > maxLength) {
return nickname.substring(0, maxLength) + '...';
}
return nickname;
}
}