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,
title: type ?? 'UNKNOWN',
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) {

View File

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

View File

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

View File

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

View File

@ -3,22 +3,22 @@ part of 'home_page.dart';
typedef OnReactionCallback = void Function(
String? id, String nickname, bool isLiked, bool isDisliked)?;
class _Comment extends StatelessWidget {
class _Card extends StatelessWidget {
final String? id;
final String title;
final String text;
final CharacterData user;
final CharacterData character;
final bool isLiked;
final bool isDisliked;
final OnReactionCallback? onLike;
final OnReactionCallback? onDislike;
final VoidCallback? onTap;
const _Comment({
const _Card({
this.id,
required this.title,
required this.text,
required this.user,
required this.character,
this.isLiked = false,
this.isDisliked = false,
this.onLike,
@ -26,7 +26,7 @@ class _Comment extends StatelessWidget {
this.onTap,
});
factory _Comment.fromData(
factory _Card.fromData(
CardData data, {
bool isLiked = false,
bool isDisliked = false,
@ -34,11 +34,11 @@ class _Comment extends StatelessWidget {
OnReactionCallback? onDislike,
VoidCallback? onTap,
}) =>
_Comment(
_Card(
id: data.id,
title: data.title,
text: data.text,
user: data.user,
character: data.character,
isLiked: isLiked,
isDisliked: isDisliked,
onLike: onLike,
@ -47,11 +47,11 @@ class _Comment extends StatelessWidget {
);
void _onLike() {
onLike?.call(id, user.name, isLiked, isDisliked);
onLike?.call(id, character.name, isLiked, isDisliked);
}
void _onDislike() {
onDislike?.call(id, user.name, isLiked, isDisliked);
onDislike?.call(id, character.name, isLiked, isDisliked);
}
@override
@ -84,9 +84,9 @@ class _Comment extends StatelessWidget {
child: SizedBox(
height: 80,
width: 80,
child: user.avatarUrl != null && user.avatarUrl!.isNotEmpty
child: character.avatarUrl != null && character.avatarUrl!.isNotEmpty
? Image.network(
user.avatarUrl!,
character.avatarUrl!,
fit: BoxFit.cover,
)
: Container(
@ -101,7 +101,7 @@ class _Comment extends StatelessWidget {
SizedBox(
width: 80,
child: Text(
user.name,
character.name,
style: Theme.of(context).textTheme.bodyMedium,
maxLines: 1,
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_state.dart';
part 'comment.dart';
part 'card.dart';
class HomePage extends StatefulWidget {
const HomePage({super.key, required this.title});
@ -168,7 +168,7 @@ class _BodyState extends State<_Body> {
itemBuilder: (context, index) {
final data = state.data?.data?[index];
return data != null
? _Comment.fromData(
? _Card.fromData(
data,
onLike: _onLike,
onDislike: _onDislike,