Skip to content

Commit

Permalink
fix: favorites screen. (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
Livinglist authored Sep 23, 2024
1 parent a4ae6a2 commit bbed4e0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 29 deletions.
3 changes: 3 additions & 0 deletions lib/repositories/sembast_repository.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:io';

import 'package:hacki/cubits/cubits.dart';
import 'package:hacki/extensions/extensions.dart';
import 'package:hacki/models/models.dart';
import 'package:hacki/services/services.dart';
Expand All @@ -10,6 +11,8 @@ import 'package:sembast/sembast.dart';
import 'package:sembast/sembast_io.dart';

/// [SembastRepository] is for storing stories and comments for faster loading.
/// This is currently used by [TimeMachineCubit], [NotificationCubit] and
/// [FavCubit].
///
/// Sembast [Database] is used as its database and is being stored in the
/// documents directory assigned by host system which you can retrieve
Expand Down
51 changes: 25 additions & 26 deletions lib/screens/profile/widgets/favorites_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class FavoritesScreen extends StatelessWidget {
previous.favItems.length != current.favItems.length ||
previous.isDisplayingStories != current.isDisplayingStories,
builder: (BuildContext context, FavState favState) {
Widget? header() => authState.isLoggedIn
? Column(
children: <Widget>[
Widget? header() => Column(
children: <Widget>[
if (authState.isLoggedIn)
BlocSelector<FavCubit, FavState, Status>(
selector: (FavState state) => state.mergeStatus,
builder: (
Expand Down Expand Up @@ -69,29 +69,28 @@ class FavoritesScreen extends StatelessWidget {
);
},
),
Row(
children: <Widget>[
const SizedBox(
width: Dimens.pt12,
),
CustomChip(
selected: favState.isDisplayingStories,
label: 'Story',
onSelected: (_) => context.read<FavCubit>().switchTab(),
),
const SizedBox(
width: Dimens.pt12,
),
CustomChip(
selected: !favState.isDisplayingStories,
label: 'Comment',
onSelected: (_) => context.read<FavCubit>().switchTab(),
),
],
),
],
)
: null;
Row(
children: <Widget>[
const SizedBox(
width: Dimens.pt12,
),
CustomChip(
selected: favState.isDisplayingStories,
label: 'Story',
onSelected: (_) => context.read<FavCubit>().switchTab(),
),
const SizedBox(
width: Dimens.pt12,
),
CustomChip(
selected: !favState.isDisplayingStories,
label: 'Comment',
onSelected: (_) => context.read<FavCubit>().switchTab(),
),
],
),
],
);

if (favState.favItems.isEmpty && favState.status != Status.inProgress) {
return Column(
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ packages:
dependency: "direct main"
description:
name: dio
sha256: "0dfb6b6a1979dac1c1245e17cef824d7b452ea29bd33d3467269f9bef3715fb0"
sha256: "5598aa796bbf4699afd5c67c0f5f6e2ed542afc956884b9cd58c306966efc260"
url: "https://pub.dev"
source: hosted
version: "5.6.0"
version: "5.7.0"
dio_smart_retry:
dependency: "direct main"
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies:
collection: ^1.17.1
connectivity_plus: ^6.0.3
device_info_plus: ^10.1.0
dio: ^5.4.3+1
dio: ^5.7.0
dio_smart_retry: ^6.0.0
equatable: ^2.0.5
fast_gbk: ^1.0.0
Expand Down

0 comments on commit bbed4e0

Please sign in to comment.