LabWork07 minor changes

This commit is contained in:
parent 10e0166740
commit a4fcdc5715
2 changed files with 9 additions and 10 deletions

View File

@ -2,7 +2,6 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.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/components/locale/l10n/app_locale.dart';
import 'package:pmu_labworks/data/repositories/potterdb_repository.dart'; import 'package:pmu_labworks/data/repositories/potterdb_repository.dart';
import 'package:pmu_labworks/view/home_page/bloc/bloc.dart'; import 'package:pmu_labworks/view/home_page/bloc/bloc.dart';
@ -44,7 +43,7 @@ class MyApp extends StatelessWidget {
child: BlocProvider<HomeBloc>( child: BlocProvider<HomeBloc>(
lazy: false, lazy: false,
create: (context) => HomeBloc(context.read<PotterDBRepository>()), create: (context) => HomeBloc(context.read<PotterDBRepository>()),
child: HomePage(title: "Comments App"), child: const HomePage(title: "Comments App"),
), ),
), ),
), ),

View File

@ -1,8 +1,6 @@
part of 'home_page.dart'; part of 'home_page.dart';
typedef OnLikeCallback = void Function( typedef OnReactionCallback = void Function(
String? id, String nickname, bool isLiked, bool isDisliked)?;
typedef OnDislikeCallback = void Function(
String? id, String nickname, bool isLiked, bool isDisliked)?; String? id, String nickname, bool isLiked, bool isDisliked)?;
class _Comment extends StatelessWidget { class _Comment extends StatelessWidget {
@ -12,8 +10,8 @@ class _Comment extends StatelessWidget {
final UserData user; final UserData user;
final bool isLiked; final bool isLiked;
final bool isDisliked; final bool isDisliked;
final OnLikeCallback? onLike; final OnReactionCallback? onLike;
final OnDislikeCallback? onDislike; final OnReactionCallback? onDislike;
final VoidCallback? onTap; final VoidCallback? onTap;
const _Comment({ const _Comment({
@ -32,8 +30,8 @@ class _Comment extends StatelessWidget {
CommentData data, { CommentData data, {
bool isLiked = false, bool isLiked = false,
bool isDisliked = false, bool isDisliked = false,
OnLikeCallback? onLike, OnReactionCallback? onLike,
OnDislikeCallback? onDislike, OnReactionCallback? onDislike,
VoidCallback? onTap, VoidCallback? onTap,
}) => }) =>
_Comment( _Comment(
@ -123,7 +121,9 @@ class _Comment extends StatelessWidget {
IconButton( IconButton(
iconSize: 20, iconSize: 20,
icon: Icon( icon: Icon(
isDisliked ? Icons.thumb_down : Icons.thumb_down_outlined, isDisliked
? Icons.thumb_down
: Icons.thumb_down_outlined,
color: isDisliked ? Colors.red : Colors.grey, color: isDisliked ? Colors.red : Colors.grey,
), ),
onPressed: _onDislike, onPressed: _onDislike,