Skip to content

Commit

Permalink
Merge pull request #72 from What-the-Flutter/v0.4.0
Browse files Browse the repository at this point in the history
0.4.0
  • Loading branch information
KirillSergeevich authored Sep 22, 2023
2 parents a80d94f + 714ca2f commit 9663458
Show file tree
Hide file tree
Showing 27 changed files with 941 additions and 2,634 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ jobs:
- name: Analyze
run: flutter analyze

- name: Test
run: flutter test

- name: Check Pana
run: pana --no-warning --exit-code-threshold 10

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.4.0
* New parameter `navigatorKey`
* Ability to delete the comment for owner and admin
* Delete `flutter_bloc` dependency

## 0.3.1
* Use AppBarTheme instead of SuggestionsAppBar [#65](https://github.com/What-the-Flutter/Suggest-a-Feature/pull/65)
* Get rid of flutter-localizations [#58](https://github.com/What-the-Flutter/Suggest-a-Feature/pull/58)
Expand Down
35 changes: 20 additions & 15 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class MyApp extends StatelessWidget {
return MaterialApp(
title: 'Suggest a Feature',
theme: ThemeData(useMaterial3: true),
navigatorKey: navigatorKey,
home: Scaffold(
body: SuggestionsPage(
onGetUserById: (id) => Future<SuggestionAuthor>(
Expand All @@ -33,12 +34,15 @@ class MyApp extends StatelessWidget {
userId: '1',
isAdmin: true,
adminSettings: _adminSettings,
navigatorKey: navigatorKey,
),
),
);
}
}

final navigatorKey = GlobalKey<NavigatorState>();

const SuggestionAuthor _suggestionAuthor = SuggestionAuthor(
id: '1',
username: 'Author',
Expand All @@ -50,7 +54,7 @@ const AdminSettings _adminSettings = AdminSettings(

class MySuggestionDataSource implements SuggestionsDataSource {
final Map<String, Suggestion> _suggestions = <String, Suggestion>{
'mockDataSuggestion1': Suggestion(
'1': Suggestion(
id: '1',
title: 'Hashtags',
authorId: '1',
Expand All @@ -59,7 +63,7 @@ class MySuggestionDataSource implements SuggestionsDataSource {
description: 'Ability to add and filter events with #hashtags',
status: SuggestionStatus.requests,
),
'mockDataSuggestion2': Suggestion(
'2': Suggestion(
id: '2',
title: 'Import/Export as pdf',
authorId: '2',
Expand All @@ -69,7 +73,7 @@ class MySuggestionDataSource implements SuggestionsDataSource {
description: 'Feature to import and export events',
status: SuggestionStatus.requests,
),
'mockDataSuggestion3': Suggestion(
'3': Suggestion(
id: '3',
title: 'Notification',
authorId: '3',
Expand All @@ -78,7 +82,7 @@ class MySuggestionDataSource implements SuggestionsDataSource {
description: 'Implement notification date change',
status: SuggestionStatus.inProgress,
),
'mockDataSuggestion4': Suggestion(
'4': Suggestion(
id: '4',
title: 'Video',
authorId: '4',
Expand All @@ -88,7 +92,7 @@ class MySuggestionDataSource implements SuggestionsDataSource {
description: 'Аbility to save video',
status: SuggestionStatus.inProgress,
),
'mockDataSuggestion5': Suggestion(
'5': Suggestion(
id: '5',
title: 'Image',
authorId: '5',
Expand All @@ -98,7 +102,7 @@ class MySuggestionDataSource implements SuggestionsDataSource {
description: 'Poor image quality',
status: SuggestionStatus.completed,
),
'mockDataSuggestion6': Suggestion(
'6': Suggestion(
id: '6',
title: 'Offline authorization',
authorId: '6',
Expand All @@ -108,7 +112,7 @@ class MySuggestionDataSource implements SuggestionsDataSource {
),
};
final Map<String, Comment> _comments = <String, Comment>{
'mockDataComment1': Comment(
'1': Comment(
author: _suggestionAuthor,
id: '1',
suggestionId: '1',
Expand All @@ -117,7 +121,7 @@ class MySuggestionDataSource implements SuggestionsDataSource {
creationTime: DateTime.now(),
isFromAdmin: true,
),
'mockDataComment2': Comment(
'2': Comment(
author: _suggestionAuthor,
id: '2',
suggestionId: '2',
Expand All @@ -126,7 +130,7 @@ class MySuggestionDataSource implements SuggestionsDataSource {
creationTime: DateTime.now(),
isFromAdmin: false,
),
'mockDataComment3': Comment(
'3': Comment(
author: _suggestionAuthor,
id: '3',
suggestionId: '3',
Expand All @@ -135,7 +139,7 @@ class MySuggestionDataSource implements SuggestionsDataSource {
creationTime: DateTime.now(),
isFromAdmin: true,
),
'mockDataComment4': Comment(
'4': Comment(
author: _suggestionAuthor,
id: '4',
suggestionId: '4',
Expand All @@ -144,7 +148,7 @@ class MySuggestionDataSource implements SuggestionsDataSource {
creationTime: DateTime.now(),
isFromAdmin: true,
),
'mockDataComment5': Comment(
'5': Comment(
author: _suggestionAuthor,
id: '5',
suggestionId: '5',
Expand All @@ -153,7 +157,7 @@ class MySuggestionDataSource implements SuggestionsDataSource {
creationTime: DateTime.now(),
isFromAdmin: false,
),
'mockDataComment6': Comment(
'6': Comment(
author: _suggestionAuthor,
id: '6',
suggestionId: '6',
Expand Down Expand Up @@ -231,8 +235,10 @@ class MySuggestionDataSource implements SuggestionsDataSource {
: <Comment>[];

@override
Future<void> deleteCommentById(String commentId) async =>
_comments.remove(commentId);
Future<void> deleteCommentById(String commentId) async {
_comments.removeWhere((_, comment) => comment.id == commentId);
}


@override
Future<void> addNotifyToUpdateUser(String suggestionId) async {
Expand Down Expand Up @@ -261,7 +267,6 @@ class MySuggestionDataSource implements SuggestionsDataSource {
final modifiedSet = {
..._suggestions[suggestionId]!.votedUserIds,
}..add(userId);

_suggestions[suggestionId] = _suggestions[suggestionId]!.copyWith(
votedUserIds: modifiedSet,
);
Expand Down
72 changes: 20 additions & 52 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.11.0"
bloc:
dependency: transitive
description:
name: bloc
sha256: "658a5ae59edcf1e58aac98b000a71c762ad8f46f1394c34a52050cafb3e11a80"
url: "https://pub.dev"
source: hosted
version: "8.1.1"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -53,10 +45,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
url: "https://pub.dev"
source: hosted
version: "1.17.1"
version: "1.17.2"
cupertino_icons:
dependency: "direct main"
description:
Expand Down Expand Up @@ -86,14 +78,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_bloc:
dependency: transitive
description:
name: flutter_bloc
sha256: e74efb89ee6945bcbce74a5b3a5a3376b088e5f21f55c263fc38cbdc6237faae
url: "https://pub.dev"
source: hosted
version: "8.1.3"
flutter_lints:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -123,14 +107,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.18.0"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
lints:
dependency: transitive
description:
Expand All @@ -143,18 +119,18 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.15"
version: "0.12.16"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.2.0"
version: "0.5.0"
meta:
dependency: transitive
description:
Expand All @@ -163,14 +139,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.9.1"
nested:
dependency: transitive
description:
name: nested
sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
path:
dependency: transitive
description:
Expand All @@ -195,14 +163,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.4.0"
provider:
dependency: transitive
description:
name: provider
sha256: cdbe7530b12ecd9eb455bdaa2fcb8d4dad22e80b8afb4798b41479d5ce26847f
url: "https://pub.dev"
source: hosted
version: "6.0.5"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -212,10 +172,10 @@ packages:
dependency: transitive
description:
name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -246,7 +206,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.3.0"
version: "0.3.1"
term_glyph:
dependency: transitive
description:
Expand All @@ -259,10 +219,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
url: "https://pub.dev"
source: hosted
version: "0.5.1"
version: "0.6.0"
vector_graphics:
dependency: transitive
description:
Expand Down Expand Up @@ -295,6 +255,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
web:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
wtf_sliding_sheet:
dependency: transitive
description:
Expand All @@ -312,5 +280,5 @@ packages:
source: hosted
version: "6.3.0"
sdks:
dart: ">=3.0.0 <4.0.0"
dart: ">=3.1.0-185.0.dev <4.0.0"
flutter: ">=3.7.0-0"
4 changes: 4 additions & 0 deletions lib/src/data/repositories/suggestion_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,8 @@ class SuggestionRepositoryImpl implements SuggestionRepository {
@override
Future<Comment> createComment(CreateCommentModel comment) =>
_suggestionsDataSource.createComment(comment);

@override
Future<void> deleteCommentById(String commentId) =>
_suggestionsDataSource.deleteCommentById(commentId);
}
1 change: 1 addition & 0 deletions lib/src/domain/data_interfaces/suggestion_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ abstract class SuggestionRepository {

Future<List<Comment>> getAllComments(String suggestionId);
Future<Comment> createComment(CreateCommentModel comment);
Future<void> deleteCommentById(String commentId);
}
7 changes: 7 additions & 0 deletions lib/src/presentation/di/injector.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/widgets.dart';
import 'package:suggest_a_feature/src/data/cache_data_source.dart';
import 'package:suggest_a_feature/src/data/interfaces/cache_data_source.dart';
import 'package:suggest_a_feature/src/data/interfaces/suggestions_data_source.dart';
Expand Down Expand Up @@ -25,6 +26,7 @@ class _Injector {
required String userId,
required SuggestionsDataSource suggestionsDataSource,
required String locale,
GlobalKey<NavigatorState>? navigatorKey,
AdminSettings? adminSettings,
bool isAdmin = false,
Map<String, String>? imageHeaders,
Expand All @@ -45,6 +47,7 @@ class _Injector {
_adminSettings = adminSettings;
_isAdmin = isAdmin;
_localization = locale.localizationOptions;
_navigatorKey = navigatorKey;
}

AdminSettings? _adminSettings;
Expand Down Expand Up @@ -80,4 +83,8 @@ class _Injector {
late LocalizationOptions _localization;

LocalizationOptions get localizations => _localization;

late GlobalKey<NavigatorState>? _navigatorKey;

GlobalKey<NavigatorState>? get navigatorKey => _navigatorKey;
}
Loading

0 comments on commit 9663458

Please sign in to comment.