Coursework: rename some classes

This commit is contained in:
parent 3bcd01be43
commit 490a79262d
6 changed files with 26 additions and 26 deletions

View File

@ -15,7 +15,7 @@ extension CharacterDataDtoToModel on CharacterDataDto {
id: id, id: id,
title: type ?? 'UNKNOWN', title: type ?? 'UNKNOWN',
text: _makeDescriptionText(attributes?.born, attributes?.died), text: _makeDescriptionText(attributes?.born, attributes?.died),
user: CharacterData(name: attributes?.name ?? 'Noname', avatarUrl: attributes?.image), character: CharacterData(name: attributes?.name ?? 'Noname', avatarUrl: attributes?.image),
); );
String _makeDescriptionText(String? born, String? died) { String _makeDescriptionText(String? born, String? died) {

View File

@ -10,7 +10,7 @@ class MockRepository extends ApiInterface {
CardData( CardData(
title: 'Oh my god', title: 'Oh my god',
text: 'this app is so cool ' * 10, text: 'this app is so cool ' * 10,
user: CharacterData( character: CharacterData(
name: 'Steve', name: 'Steve',
avatarUrl: 'https://preview.free3d.com/img/2016/03/1875481443430303321/hld8c0oa.jpg', avatarUrl: 'https://preview.free3d.com/img/2016/03/1875481443430303321/hld8c0oa.jpg',
), ),
@ -18,7 +18,7 @@ class MockRepository extends ApiInterface {
CardData( CardData(
title: 'Listen to me', title: 'Listen to me',
text: 'This app is like Half-Life 3 - it will never be released', text: 'This app is like Half-Life 3 - it will never be released',
user: CharacterData( character: CharacterData(
name: 'G-Man', name: 'G-Man',
avatarUrl: avatarUrl:
'https://us-tuna-sounds-images.voicemod.net/356aeabd-18d5-40d8-af31-b479f4eff183-1704672174928.png', 'https://us-tuna-sounds-images.voicemod.net/356aeabd-18d5-40d8-af31-b479f4eff183-1704672174928.png',
@ -27,7 +27,7 @@ class MockRepository extends ApiInterface {
CardData( CardData(
title: 'BREAKING!!!', title: 'BREAKING!!!',
text: 'ONLY NOW you can purchase the ability to put likes and dislikes for only 299\$', text: 'ONLY NOW you can purchase the ability to put likes and dislikes for only 299\$',
user: CharacterData( character: CharacterData(
name: 'Bethesda', name: 'Bethesda',
avatarUrl: 'https://i.playground.ru/p/BWixorSTeZQfoPvdVL9lgA.jpeg', avatarUrl: 'https://i.playground.ru/p/BWixorSTeZQfoPvdVL9lgA.jpeg',
), ),
@ -35,14 +35,14 @@ class MockRepository extends ApiInterface {
CardData( CardData(
title: 'Test', title: 'Test',
text: 'Test', text: 'Test',
user: CharacterData( character: CharacterData(
name: 'Noname', name: 'Noname',
), ),
), ),
CardData( CardData(
title: 'Test', title: 'Test',
text: 'Test', text: 'Test',
user: CharacterData( character: CharacterData(
name: 'Noname', name: 'Noname',
), ),
), ),

View File

@ -4,12 +4,12 @@ class CardData {
final String? id; final String? id;
final String title; final String title;
final String text; final String text;
final CharacterData user; final CharacterData character;
CardData({ CardData({
this.id, this.id,
required this.title, required this.title,
required this.text, required this.text,
required this.user, required this.character,
}); });
} }

View File

@ -12,7 +12,7 @@ class DetailsPage extends StatelessWidget {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text( title: Text(
context.locale.comment(model.user.name), context.locale.comment(model.character.name),
), ),
), ),
body: Padding( body: Padding(
@ -24,9 +24,9 @@ class DetailsPage extends StatelessWidget {
children: [ children: [
ClipRRect( ClipRRect(
borderRadius: BorderRadius.circular(8.0), borderRadius: BorderRadius.circular(8.0),
child: model.user.avatarUrl != null child: model.character.avatarUrl != null
? Image.network( ? Image.network(
model.user.avatarUrl!, model.character.avatarUrl!,
height: 150, height: 150,
width: 150, width: 150,
fit: BoxFit.cover, fit: BoxFit.cover,
@ -45,7 +45,7 @@ class DetailsPage extends StatelessWidget {
padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 8.0), padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 8.0),
color: Colors.black.withOpacity(0.6), color: Colors.black.withOpacity(0.6),
child: Text( child: Text(
_shortenNickname(model.user.name, maxLength: 13), _shortenNickname(model.character.name, maxLength: 13),
style: const TextStyle( style: const TextStyle(
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,

View File

@ -3,22 +3,22 @@ part of 'home_page.dart';
typedef OnReactionCallback = void Function( typedef OnReactionCallback = void Function(
String? id, String nickname, bool isLiked, bool isDisliked)?; String? id, String nickname, bool isLiked, bool isDisliked)?;
class _Comment extends StatelessWidget { class _Card extends StatelessWidget {
final String? id; final String? id;
final String title; final String title;
final String text; final String text;
final CharacterData user; final CharacterData character;
final bool isLiked; final bool isLiked;
final bool isDisliked; final bool isDisliked;
final OnReactionCallback? onLike; final OnReactionCallback? onLike;
final OnReactionCallback? onDislike; final OnReactionCallback? onDislike;
final VoidCallback? onTap; final VoidCallback? onTap;
const _Comment({ const _Card({
this.id, this.id,
required this.title, required this.title,
required this.text, required this.text,
required this.user, required this.character,
this.isLiked = false, this.isLiked = false,
this.isDisliked = false, this.isDisliked = false,
this.onLike, this.onLike,
@ -26,7 +26,7 @@ class _Comment extends StatelessWidget {
this.onTap, this.onTap,
}); });
factory _Comment.fromData( factory _Card.fromData(
CardData data, { CardData data, {
bool isLiked = false, bool isLiked = false,
bool isDisliked = false, bool isDisliked = false,
@ -34,11 +34,11 @@ class _Comment extends StatelessWidget {
OnReactionCallback? onDislike, OnReactionCallback? onDislike,
VoidCallback? onTap, VoidCallback? onTap,
}) => }) =>
_Comment( _Card(
id: data.id, id: data.id,
title: data.title, title: data.title,
text: data.text, text: data.text,
user: data.user, character: data.character,
isLiked: isLiked, isLiked: isLiked,
isDisliked: isDisliked, isDisliked: isDisliked,
onLike: onLike, onLike: onLike,
@ -47,11 +47,11 @@ class _Comment extends StatelessWidget {
); );
void _onLike() { void _onLike() {
onLike?.call(id, user.name, isLiked, isDisliked); onLike?.call(id, character.name, isLiked, isDisliked);
} }
void _onDislike() { void _onDislike() {
onDislike?.call(id, user.name, isLiked, isDisliked); onDislike?.call(id, character.name, isLiked, isDisliked);
} }
@override @override
@ -84,9 +84,9 @@ class _Comment extends StatelessWidget {
child: SizedBox( child: SizedBox(
height: 80, height: 80,
width: 80, width: 80,
child: user.avatarUrl != null && user.avatarUrl!.isNotEmpty child: character.avatarUrl != null && character.avatarUrl!.isNotEmpty
? Image.network( ? Image.network(
user.avatarUrl!, character.avatarUrl!,
fit: BoxFit.cover, fit: BoxFit.cover,
) )
: Container( : Container(
@ -101,7 +101,7 @@ class _Comment extends StatelessWidget {
SizedBox( SizedBox(
width: 80, width: 80,
child: Text( child: Text(
user.name, character.name,
style: Theme.of(context).textTheme.bodyMedium, style: Theme.of(context).textTheme.bodyMedium,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,

View File

@ -19,7 +19,7 @@ import 'package:pmu_labworks/view/locale_bloc/locale_bloc.dart';
import 'package:pmu_labworks/view/locale_bloc/locale_events.dart'; import 'package:pmu_labworks/view/locale_bloc/locale_events.dart';
import 'package:pmu_labworks/view/locale_bloc/locale_state.dart'; import 'package:pmu_labworks/view/locale_bloc/locale_state.dart';
part 'comment.dart'; part 'card.dart';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
const HomePage({super.key, required this.title}); const HomePage({super.key, required this.title});
@ -168,7 +168,7 @@ class _BodyState extends State<_Body> {
itemBuilder: (context, index) { itemBuilder: (context, index) {
final data = state.data?.data?[index]; final data = state.data?.data?[index];
return data != null return data != null
? _Comment.fromData( ? _Card.fromData(
data, data,
onLike: _onLike, onLike: _onLike,
onDislike: _onDislike, onDislike: _onDislike,