-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### What does this PR do? This PR adds UI and additional logic for sending a post reply ### Changes Brought by This PR - Added assets - Added `ReplySentNotification` to display success message - Added `ReplyDataNotifier` to hold reply data (only text for now) - Added `SendReplyRequestNotifier` to simulate sending request - Refactored PostDetailsPage and ReplyExpandedPage to use `postId` instead of `postData` ![CleanShot 2024-07-29 at 09 42 35@2x](https://github.com/user-attachments/assets/25289576-3d39-4b65-9dad-86e078c24ccc) --------- Co-authored-by: ice-tychon <https://github.com/ice-blockchain/flutter-app/commits/master/>
- Loading branch information
1 parent
982eec7
commit f57a6c0
Showing
20 changed files
with
267 additions
and
31 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
|
||
extension AsyncValueListener on WidgetRef { | ||
void listenAsyncValue<TSuccess>( | ||
ProviderListenable<AsyncValue<TSuccess?>> provider, { | ||
void Function()? onLoading, | ||
void Function(TSuccess? response)? onSuccess, | ||
void Function(Object erorr, StackTrace stackTrace)? onFailure, | ||
bool skipLoadingOnReload = false, | ||
bool skipLoadingOnRefresh = true, | ||
bool skipError = false, | ||
}) { | ||
listen(provider, (previous, next) { | ||
next.whenOrNull( | ||
loading: onLoading, | ||
data: onSuccess, | ||
error: onFailure, | ||
skipError: skipError, | ||
skipLoadingOnRefresh: skipLoadingOnRefresh, | ||
skipLoadingOnReload: skipLoadingOnReload, | ||
); | ||
}); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
lib/app/features/feed/model/post_reply/post_reply_data.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
part 'post_reply_data.freezed.dart'; | ||
|
||
@Freezed(copyWith: true) | ||
class PostReplyData with _$PostReplyData { | ||
const factory PostReplyData({ | ||
required String text, | ||
}) = _PostReplyData; | ||
|
||
factory PostReplyData.empty() => PostReplyData( | ||
text: '', | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:ice/app/features/feed/model/post/post_data.dart'; | ||
import 'package:nostr_dart/nostr_dart.dart'; | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
part 'post_by_id_provider.g.dart'; | ||
|
||
@riverpod | ||
PostData? postById(PostByIdRef ref, { | ||
required String id, | ||
}) { | ||
return PostData.fromEventMessage( | ||
EventMessage.fromJson( | ||
json.decode( | ||
r'["EVENT","5f6556d1-9a5e-4092-a7e3-a202857b445f",{"content":"GM https://image.nostr.build/d84c3d3a7abfa358106cad5a3ec0cc0888733f4cacda2b49cf3d7f9519003698.jpg","created_at":1720428050,"id":"0454657a5edeedf3db10b37dd5a3ca387f5714a2675f7e51539475e8fcb331de","kind":1,"pubkey":"d0c01dd5931409d2bc7e58ee4908e6366ff0fd722d20e9c709fde6846f3ceabb","sig":"263b97d9157f602b944859ebd3fe56851a5a786379bf38f7e81f6a58ec7acc5bca412f1e3a488ada033e240977bbc134f2f5047e4a9df32dcd19d96126c8a9ed","tags":[["e","6f2f2e100c8075d5ebae5866544ae243aad9e56916c3cb33e7a69c69004858e6","","root"],["p","6e468422dfb74a5738702a8823b9b28168abab8655faacb6853cd0ee15deee93"],["r","https://image.nostr.build/d84c3d3a7abfa358106cad5a3ec0cc0888733f4cacda2b49cf3d7f9519003698.jpg"],["imeta","url https://image.nostr.build/d84c3d3a7abfa358106cad5a3ec0cc0888733f4cacda2b49cf3d7f9519003698.jpg","m image/jpeg","alt Verifiable file url","x 1dc63792be80c939b207f089f69221df8755c0f6e38503f666e4619f1ccf9a12","size 340088","dim 864x1920","blurhash [[email protected];W?nzbdEFo$WBj]NPahjqj]o}bIofWUt7oHWEj=IVocjYa}Mwn$WYfRsiW=a#oI","ox d84c3d3a7abfa358106cad5a3ec0cc0888733f4cacda2b49cf3d7f9519003698"]]}]', | ||
) as List<dynamic>, | ||
), | ||
); | ||
} |
20 changes: 20 additions & 0 deletions
20
lib/app/features/feed/providers/post_reply/reply_data_notifier.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:ice/app/features/feed/model/post_reply/post_reply_data.dart'; | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
part 'reply_data_notifier.g.dart'; | ||
|
||
@riverpod | ||
class ReplyDataNotifier extends _$ReplyDataNotifier { | ||
@override | ||
PostReplyData build() { | ||
return PostReplyData.empty(); | ||
} | ||
|
||
void onTextChanged(String newValue) { | ||
state = state.copyWith(text: newValue); | ||
} | ||
|
||
void clear() { | ||
state = PostReplyData.empty(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
lib/app/features/feed/providers/post_reply/send_reply_request_notifier.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
part 'send_reply_request_notifier.g.dart'; | ||
|
||
@riverpod | ||
class SendReplyRequestNotifier extends _$SendReplyRequestNotifier { | ||
@override | ||
FutureOr<void> build() {} | ||
|
||
Future<void> sendReply() async { | ||
state = AsyncValue.loading(); | ||
await Future<void>.delayed(Duration(seconds: 1)); | ||
state = AsyncValue.data(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...features/feed/views/pages/post_details_page/components/post_not_found/post_not_found.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:ice/app/extensions/extensions.dart'; | ||
import 'package:ice/app/router/components/navigation_app_bar/navigation_app_bar.dart'; | ||
|
||
class PostNotFound extends StatelessWidget { | ||
const PostNotFound({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: NavigationAppBar.screen( | ||
title: Text(context.i18n.post_page_title), | ||
), | ||
body: Center( | ||
child: Text('Post not found'), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...s/pages/post_details_page/components/reply_sent_notification/reply_sent_notification.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:ice/app/extensions/extensions.dart'; | ||
import 'package:ice/generated/assets.gen.dart'; | ||
|
||
class ReplySentNotification extends StatelessWidget { | ||
const ReplySentNotification({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final colors = context.theme.appColors; | ||
final textStyles = context.theme.appTextThemes; | ||
|
||
return SizedBox( | ||
height: 54.0.s, | ||
child: DecoratedBox( | ||
decoration: BoxDecoration( | ||
borderRadius: BorderRadius.circular(16.0.s), | ||
color: colors.primaryAccent, | ||
), | ||
child: Padding( | ||
padding: EdgeInsets.symmetric(horizontal: 15.0.s), | ||
child: Row( | ||
children: [ | ||
Assets.images.icons.iconBlockCheckboxOnWhite.icon(), | ||
SizedBox(width: 8.0.s), | ||
Text( | ||
context.i18n.post_reply_sent, | ||
style: textStyles.subtitle2.copyWith(color: colors.onPrimaryAccent), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.