From a4fcdc571510c249e8dcff4a5d24eef4c2ca73f6 Mon Sep 17 00:00:00 2001 From: Factorino73 Date: Wed, 2 Oct 2024 03:32:10 +0400 Subject: [PATCH] LabWork07 minor changes --- lib/main.dart | 3 +-- lib/view/home_page/comment.dart | 16 ++++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index afe524b..804ad72 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:pmu_labworks/components/extensions/context_x.dart'; import 'package:pmu_labworks/components/locale/l10n/app_locale.dart'; import 'package:pmu_labworks/data/repositories/potterdb_repository.dart'; import 'package:pmu_labworks/view/home_page/bloc/bloc.dart'; @@ -44,7 +43,7 @@ class MyApp extends StatelessWidget { child: BlocProvider( lazy: false, create: (context) => HomeBloc(context.read()), - child: HomePage(title: "Comments App"), + child: const HomePage(title: "Comments App"), ), ), ), diff --git a/lib/view/home_page/comment.dart b/lib/view/home_page/comment.dart index 25d54b2..ae41074 100644 --- a/lib/view/home_page/comment.dart +++ b/lib/view/home_page/comment.dart @@ -1,8 +1,6 @@ part of 'home_page.dart'; -typedef OnLikeCallback = void Function( - String? id, String nickname, bool isLiked, bool isDisliked)?; -typedef OnDislikeCallback = void Function( +typedef OnReactionCallback = void Function( String? id, String nickname, bool isLiked, bool isDisliked)?; class _Comment extends StatelessWidget { @@ -12,8 +10,8 @@ class _Comment extends StatelessWidget { final UserData user; final bool isLiked; final bool isDisliked; - final OnLikeCallback? onLike; - final OnDislikeCallback? onDislike; + final OnReactionCallback? onLike; + final OnReactionCallback? onDislike; final VoidCallback? onTap; const _Comment({ @@ -32,8 +30,8 @@ class _Comment extends StatelessWidget { CommentData data, { bool isLiked = false, bool isDisliked = false, - OnLikeCallback? onLike, - OnDislikeCallback? onDislike, + OnReactionCallback? onLike, + OnReactionCallback? onDislike, VoidCallback? onTap, }) => _Comment( @@ -123,7 +121,9 @@ class _Comment extends StatelessWidget { IconButton( iconSize: 20, icon: Icon( - isDisliked ? Icons.thumb_down : Icons.thumb_down_outlined, + isDisliked + ? Icons.thumb_down + : Icons.thumb_down_outlined, color: isDisliked ? Colors.red : Colors.grey, ), onPressed: _onDislike,