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( title: Text( '${_shortenNickname(model.user.nickname)}\'s comment', ), ), 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; } }