-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introducing Socialised Stories Updates #2537
base: main
Are you sure you want to change the base?
Changes from 35 commits
b050510
5d0316a
c3ec2a0
a8ec33d
a90e2bc
2050742
832cb22
a2efec1
6f659d5
43d8f3a
522c1ab
91ffef6
ef7157a
8c7db75
fab262e
f8c409b
f444715
eceff2a
9337f52
16210c6
4d19d34
9572bb2
b20c9dd
42a2068
e18e30a
4a247e9
038ae0d
c91fcc7
2a018c3
dd85516
30082f6
f246177
d8e8c11
8a78093
2c4a497
01786a8
048ee99
b8acaa0
f97e6d3
179dc7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import 'package:acter/common/utils/constants.dart'; | |
import 'package:acter/features/home/data/keys.dart'; | ||
import 'package:acter/features/news/model/keys.dart'; | ||
import 'package:acter/features/news/model/news_slide_model.dart'; | ||
import 'package:acter/features/news/pages/add_news_page.dart'; | ||
import 'package:acter/features/news/pages/add_news/add_news_page.dart'; | ||
import 'package:acter/features/news/providers/news_post_editor_providers.dart'; | ||
import 'package:acter/features/search/model/keys.dart'; | ||
import 'package:acter/features/space/dialogs/leave_space.dart'; | ||
|
@@ -33,16 +33,15 @@ extension ActerNews on ConvenientTest { | |
} | ||
|
||
Future<void> toggleBackgroundColor() async { | ||
final slideBackgroundColorKey = | ||
find.byKey(NewsUpdateKeys.slideBackgroundColor); | ||
final slideBackgroundColorKey = find.byKey(UpdateKeys.slideBackgroundColor); | ||
await slideBackgroundColorKey.should(findsOneWidget); | ||
await slideBackgroundColorKey.tap(); | ||
|
||
await slideBackgroundColorKey.tap(); | ||
} | ||
|
||
Future<EditorState> addTextSlide(String text) async { | ||
final addTextSlideKey = find.byKey(NewsUpdateKeys.addTextSlide); | ||
final addTextSlideKey = find.byKey(UpdateKeys.addTextSlide); | ||
await addTextSlideKey.should(findsOneWidget); | ||
await addTextSlideKey.tap(); | ||
final editorState = await _getNewsTextEditorState(); | ||
|
@@ -54,16 +53,16 @@ extension ActerNews on ConvenientTest { | |
|
||
Future<void> submitNews(String? spaceId) async { | ||
if (spaceId != null) { | ||
await selectSpace(spaceId, NewsUpdateKeys.selectSpace); | ||
await selectSpace(spaceId, UpdateKeys.selectSpace); | ||
} | ||
|
||
final submit = find.byKey(NewsUpdateKeys.newsSubmitBtn); | ||
final submit = find.byKey(UpdateKeys.newsSubmitBtn); | ||
await tester.ensureVisible(submit); | ||
await submit.tap(); | ||
} | ||
|
||
Future<void> addImageSlide({String? filepath}) async { | ||
final addImageSlideKey = find.byKey(NewsUpdateKeys.addImageSlide); | ||
final addImageSlideKey = find.byKey(UpdateKeys.addImageSlide); | ||
await addImageSlideKey.should(findsOneWidget); | ||
|
||
// Adding Image Slide Object into Slide List | ||
|
@@ -72,39 +71,39 @@ extension ActerNews on ConvenientTest { | |
final imageFile = await convertAssetImageToXFile( | ||
filepath ?? 'assets/images/update_onboard.png', | ||
); | ||
final slide = NewsSlideItem( | ||
type: NewsSlideType.image, | ||
final slide = UpdateSlideItem( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only name changes from |
||
type: UpdateSlideType.image, | ||
mediaFile: imageFile, | ||
); | ||
ref.read(newsStateProvider.notifier).addSlide(slide); | ||
} | ||
|
||
Future<void> addVideoSlide({String? filepath}) async { | ||
final addVideoSlideKey = find.byKey(NewsUpdateKeys.addVideoSlide); | ||
final addVideoSlideKey = find.byKey(UpdateKeys.addVideoSlide); | ||
await addVideoSlideKey.should(findsOneWidget); | ||
|
||
// Adding Video Slide Object into Slide List | ||
final context = tester.element(addVideoSlideKey); | ||
final ref = ProviderScope.containerOf(context); | ||
final videoFile = | ||
await convertAssetImageToXFile(filepath ?? 'assets/videos/video.mp4'); | ||
final slide = NewsSlideItem( | ||
type: NewsSlideType.video, | ||
final slide = UpdateSlideItem( | ||
type: UpdateSlideType.video, | ||
mediaFile: videoFile, | ||
); | ||
ref.read(newsStateProvider.notifier).addSlide(slide); | ||
} | ||
|
||
Future<void> openAddSlide() async { | ||
// Open bottom sheet for adding more slide | ||
final addMoreNewsKey = find.byKey(NewsUpdateKeys.addNewsSlide); | ||
final addMoreNewsKey = find.byKey(UpdateKeys.addNewsUpdate); | ||
await addMoreNewsKey.should(findsOneWidget); | ||
await addMoreNewsKey.tap(); | ||
} | ||
|
||
Future<void> closeAddSlide() async { | ||
// Close bottom sheet | ||
final cancelKey = find.byKey(NewsUpdateKeys.cancelButton); | ||
final cancelKey = find.byKey(UpdateKeys.cancelButton); | ||
await cancelKey.should(findsOneWidget); | ||
await cancelKey.tap(); | ||
} | ||
|
@@ -121,7 +120,7 @@ void updateTests() { | |
await t.submitNews(spaceId); | ||
|
||
// we expect to be thrown to the news screen and see our latest item first: | ||
final textUpdateContent = find.byKey(NewsUpdateKeys.textUpdateContent); | ||
final textUpdateContent = find.byKey(UpdateKeys.textUpdateContent); | ||
await textUpdateContent.should(findsOneWidget); | ||
await find.text(text).should(findsWidgets); | ||
}); | ||
|
@@ -156,7 +155,7 @@ void updateTests() { | |
await t.submitNews(spaceId); | ||
|
||
// we expect to be thrown to the news screen and see our latest item first: | ||
final textUpdateContent = find.byKey(NewsUpdateKeys.textUpdateContent); | ||
final textUpdateContent = find.byKey(UpdateKeys.textUpdateContent); | ||
await textUpdateContent.should(findsOneWidget); | ||
await find.text(text).should(findsOneWidget); | ||
await find | ||
|
@@ -174,7 +173,7 @@ void updateTests() { | |
await t.submitNews(spaceId); | ||
|
||
// we expect to be thrown to the news screen and see our latest item first: | ||
final imageUpdateContent = find.byKey(NewsUpdateKeys.imageUpdateContent); | ||
final imageUpdateContent = find.byKey(UpdateKeys.imageUpdateContent); | ||
await imageUpdateContent.should(findsOneWidget); | ||
}); | ||
|
||
|
@@ -187,7 +186,7 @@ void updateTests() { | |
await t.submitNews(spaceId); | ||
|
||
// we expect to be thrown to the news screen and see our latest item first: | ||
final imageUpdateContent = find.byKey(NewsUpdateKeys.imageUpdateContent); | ||
final imageUpdateContent = find.byKey(UpdateKeys.imageUpdateContent); | ||
await imageUpdateContent.should(findsOneWidget); | ||
await t.gotoSpace(spaceId); | ||
await t.navigateTo([ | ||
|
@@ -209,7 +208,7 @@ void updateTests() { | |
await t.submitNews(spaceId); | ||
|
||
// we expect to be thrown to the news screen and see our latest item first: | ||
final videoUpdateContent = find.byKey(NewsUpdateKeys.videoNewsContent); | ||
final videoUpdateContent = find.byKey(UpdateKeys.videoNewsContent); | ||
await videoUpdateContent.should(findsOneWidget); | ||
}); | ||
|
||
|
@@ -233,7 +232,7 @@ void updateTests() { | |
|
||
await t.submitNews(null); // no space selected, this will fail | ||
// so we select a space | ||
await t.selectSpace(spaceId, NewsUpdateKeys.selectSpace); | ||
await t.selectSpace(spaceId, UpdateKeys.selectSpace); | ||
await t.submitNews(null); // text is empty, so this will fail | ||
|
||
await t.trigger( | ||
|
@@ -256,7 +255,7 @@ void updateTests() { | |
|
||
// we expect to be thrown to the news screen and see our latest item first: | ||
// For Image | ||
final imageUpdateContent = find.byKey(NewsUpdateKeys.imageUpdateContent); | ||
final imageUpdateContent = find.byKey(UpdateKeys.imageUpdateContent); | ||
await imageUpdateContent.should(findsOneWidget); | ||
}); | ||
|
||
|
@@ -269,16 +268,16 @@ void updateTests() { | |
await t.submitNews(spaceId); | ||
|
||
// we expect to be thrown to the news screen and see our latest item first: | ||
final imageUpdateContent = find.byKey(NewsUpdateKeys.imageUpdateContent); | ||
final imageUpdateContent = find.byKey(UpdateKeys.imageUpdateContent); | ||
await imageUpdateContent.should(findsOneWidget); | ||
|
||
// open news sidebar bottom sheet for action buttons | ||
await t.trigger(NewsUpdateKeys.newsSidebarActionBottomSheet); | ||
await t.trigger(UpdateKeys.newsSidebarActionBottomSheet); | ||
|
||
// click on remove button for show confirm dialog | ||
await t.trigger(NewsUpdateKeys.newsSidebarActionRemoveBtn); | ||
await t.trigger(UpdateKeys.newsSidebarActionRemoveBtn); | ||
|
||
// click on remove button | ||
await t.trigger(NewsUpdateKeys.removeButton); | ||
await t.trigger(UpdateKeys.removeButton); | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ enum Routes { | |
update('/updates/:updateId([^/]+)'), | ||
updateList('/updateList'), | ||
actionAddUpdate('/actions/addUpdate'), | ||
actionAddUpdatePostTo('/actions/addUpdate/PostTo'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added new |
||
|
||
// --- search | ||
searchPublicDirectory('/search/public'), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import 'package:acter/features/news/model/type/update_entry.dart'; | ||
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart' | ||
show ActerPin, CalendarEvent, CommentsManager, NewsEntry, Task, TaskList; | ||
show ActerPin, CalendarEvent, CommentsManager, Task, TaskList; | ||
|
||
/// This is the actual input type for the providers and widget of this feature | ||
/// the way to get this is through implementing a "wrapper" type for the getter | ||
|
@@ -57,11 +58,11 @@ | |
TaskCommentsManagerProvider(this); | ||
} | ||
|
||
class NewsEntryCommentsManagerProvider implements CommentsManagerProvider { | ||
final NewsEntry inner; | ||
class UpdateEntryCommentsManagerProvider implements CommentsManagerProvider { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming changes only. |
||
final UpdateEntry inner; | ||
late String innerId; | ||
|
||
NewsEntryCommentsManagerProvider(this.inner) { | ||
UpdateEntryCommentsManagerProvider(this.inner) { | ||
innerId = inner.eventId().toString(); | ||
} | ||
|
||
|
@@ -72,12 +73,12 @@ | |
int get hashCode => innerId.hashCode; | ||
@override | ||
bool operator ==(other) => | ||
other is NewsEntryCommentsManagerProvider && innerId == other.innerId; | ||
other is UpdateEntryCommentsManagerProvider && innerId == other.innerId; | ||
} | ||
|
||
extension NewsEntryCommentsManagerProviderExtension on NewsEntry { | ||
NewsEntryCommentsManagerProvider asCommentsManagerProvider() => | ||
NewsEntryCommentsManagerProvider(this); | ||
extension UpdateEntryCommentsManagerProviderExtension on UpdateEntry { | ||
UpdateEntryCommentsManagerProvider asCommentsManagerProvider() => | ||
UpdateEntryCommentsManagerProvider(this); | ||
} | ||
|
||
class ActerPinCommentsManagerProvider implements CommentsManagerProvider { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import 'package:acter/common/providers/sdk_provider.dart'; | ||
import 'package:acter/common/utils/utils.dart'; | ||
import 'package:acter/features/home/providers/client_providers.dart'; | ||
import 'package:acter/features/news/model/news_slide_model.dart'; | ||
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:flutter_gen/gen_l10n/l10n.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:mime/mime.dart'; | ||
|
||
Future<NewsSlideDraft> makeImageSlideForNews( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No logical changes. Just copied logic from previous implementation and used it based on the post type. |
||
WidgetRef ref, | ||
UpdateSlideItem slidePost, | ||
L10n lang, | ||
) async { | ||
final imageDraft = await createImageMsgDraftDraft(ref, slidePost, lang); | ||
final imageSlideDraft = imageDraft.intoNewsSlideDraft(); | ||
|
||
final sdk = await ref.read(sdkProvider.future); | ||
imageSlideDraft.color( | ||
sdk.api.newColorizeBuilder(null, slidePost.backgroundColor?.toInt()), | ||
); | ||
|
||
final refDetails = slidePost.refDetails; | ||
if (refDetails != null) { | ||
final objRefBuilder = sdk.api.newObjRefBuilder(null, refDetails); | ||
imageSlideDraft.addReference(objRefBuilder); | ||
} | ||
return imageSlideDraft; | ||
} | ||
|
||
Future<StorySlideDraft> makeImageSlideForStory( | ||
WidgetRef ref, | ||
UpdateSlideItem slidePost, | ||
L10n lang, | ||
) async { | ||
final imageDraft = await createImageMsgDraftDraft(ref, slidePost, lang); | ||
final imageSlideDraft = imageDraft.intoStorySlideDraft(); | ||
|
||
final sdk = await ref.read(sdkProvider.future); | ||
imageSlideDraft.color( | ||
sdk.api.newColorizeBuilder(null, slidePost.backgroundColor?.toInt()), | ||
); | ||
|
||
final refDetails = slidePost.refDetails; | ||
if (refDetails != null) { | ||
final objRefBuilder = sdk.api.newObjRefBuilder(null, refDetails); | ||
imageSlideDraft.addReference(objRefBuilder); | ||
} | ||
return imageSlideDraft; | ||
} | ||
|
||
Future<MsgDraft> createImageMsgDraftDraft( | ||
WidgetRef ref, | ||
UpdateSlideItem slidePost, | ||
L10n lang, | ||
) async { | ||
final client = await ref.read(alwaysClientProvider.future); | ||
|
||
final file = slidePost.mediaFile; | ||
if (file == null) { | ||
throw 'Image File missing'; | ||
} | ||
String? mimeType = file.mimeType ?? lookupMimeType(file.path); | ||
if (mimeType == null) throw lang.failedToDetectMimeType; | ||
if (!mimeType.startsWith('image/')) { | ||
throw lang.postingOfTypeNotYetSupported(mimeType); | ||
} | ||
Uint8List bytes = await file.readAsBytes(); | ||
final decodedImage = await decodeImageFromList(bytes); | ||
final imageDraft = client | ||
.imageDraft(file.path, mimeType) | ||
.size(bytes.length) | ||
.width(decodedImage.width) | ||
.height(decodedImage.height); | ||
return imageDraft; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only name changes from
NewsUpdateKeys
toUpdateKeys