diff --git a/packages/firebase_timeline_repository/lib/src/firebase_category_repository.dart b/packages/firebase_timeline_repository/lib/src/firebase_category_repository.dart index b2cdabf..f6e675c 100644 --- a/packages/firebase_timeline_repository/lib/src/firebase_category_repository.dart +++ b/packages/firebase_timeline_repository/lib/src/firebase_category_repository.dart @@ -42,7 +42,6 @@ class FirebaseCategoryRepository implements CategoryRepositoryInterface { ); _categories.addAll(categories); } else { - // Replace or update categories in the list while keeping the "All" category intact _categories ..clear() ..add(const TimelineCategory(key: null, title: "All")) diff --git a/packages/firebase_timeline_repository/lib/src/firebase_user_repository.dart b/packages/firebase_timeline_repository/lib/src/firebase_user_repository.dart index d503743..621020c 100644 --- a/packages/firebase_timeline_repository/lib/src/firebase_user_repository.dart +++ b/packages/firebase_timeline_repository/lib/src/firebase_user_repository.dart @@ -1,6 +1,6 @@ +import "package:cloud_firestore/cloud_firestore.dart"; import "package:firebase_auth/firebase_auth.dart"; import "package:timeline_repository_interface/timeline_repository_interface.dart"; -import "package:cloud_firestore/cloud_firestore.dart"; class FirebaseUserRepository implements TimelineUserRepositoryInterface { final CollectionReference usersCollection = @@ -42,7 +42,7 @@ class FirebaseUserRepository implements TimelineUserRepositoryInterface { toFirestore: (user, _) => user.toJson(), ) .get(); - // print(userDoc.data()?.firstName); + // print(userDoc.data()?.firstName); return userDoc.data(); } } diff --git a/packages/firebase_timeline_repository/pubspec.yaml b/packages/firebase_timeline_repository/pubspec.yaml index 9e9db24..9f6847d 100644 --- a/packages/firebase_timeline_repository/pubspec.yaml +++ b/packages/firebase_timeline_repository/pubspec.yaml @@ -20,6 +20,7 @@ dependencies: cloud_firestore: ^5.4.4 firebase_auth: ^5.3.1 firebase_storage: ^12.3.2 + collection: ^1.18.0 dev_dependencies: flutter_iconica_analysis: diff --git a/packages/flutter_timeline/example/lib/main.dart b/packages/flutter_timeline/example/lib/main.dart index a5781d6..ab74f3d 100644 --- a/packages/flutter_timeline/example/lib/main.dart +++ b/packages/flutter_timeline/example/lib/main.dart @@ -1,7 +1,6 @@ import 'package:example/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_timeline/flutter_timeline.dart'; -import 'package:timeline_repository_interface/timeline_repository_interface.dart'; import 'package:intl/date_symbol_data_local.dart'; void main(List args) { @@ -25,106 +24,3 @@ class MyApp extends StatelessWidget { ); } } - -// class Titje extends StatelessWidget { -// const Titje({super.key, required this.initialCategory}); -// final String? initialCategory; - -// @override -// Widget build(BuildContext context) { -// return TimelineScreen( -// onTapComments: (post) { -// Navigator.of(context).push(MaterialPageRoute( -// builder: (context) => Detail( -// post: post, -// timelineService: timelineService, -// ))); -// }, -// onTapCreatePost: () { -// Navigator.of(context).push(MaterialPageRoute( -// builder: (context) => ChooseCategory( -// timelineService: timelineService, -// ))); -// }, -// currentUserId: "1", -// options: TimelineOptions(), -// timelineService: timelineService, -// onTapPost: (post) { -// Navigator.of(context).push(MaterialPageRoute( -// builder: (context) => Detail( -// post: post, -// timelineService: timelineService, -// ))); -// }, -// ); -// } -// } - -// class Detail extends StatelessWidget { -// const Detail({super.key, required this.post, required this.timelineService}); - -// final TimelinePost post; -// final TimelineService timelineService; - -// @override -// Widget build(BuildContext context) { -// return TimelinePostDetailScreen( -// onTapComments: (post) {}, -// onTapPost: (post) {}, -// post: post, -// timelineService: timelineService, -// options: TimelineOptions(), -// currentUserId: "1"); -// } -// } - -// class ChooseCategory extends StatelessWidget { -// const ChooseCategory({super.key, required this.timelineService}); -// final TimelineService timelineService; - -// @override -// Widget build(BuildContext context) { -// return TimelineChooseCategoryScreen( -// options: TimelineOptions(), -// timelineService: timelineService, -// ontapCategory: (category) { -// Navigator.of(context).push(MaterialPageRoute( -// builder: (context) => -// AddInformation(timelineService: timelineService))); -// }, -// ); -// } -// } - -// class AddInformation extends StatelessWidget { -// const AddInformation({super.key, required this.timelineService}); -// final TimelineService timelineService; - -// @override -// Widget build(BuildContext context) { -// return TimelineAddPostInformationScreen( -// timelineService: timelineService, -// onTaponTapOverview: () { -// Navigator.of(context).push(MaterialPageRoute( -// builder: (context) => Overview(timelineService: timelineService))); -// }, -// ); -// } -// } - -// class Overview extends StatelessWidget { -// const Overview({super.key, required this.timelineService}); -// final TimelineService timelineService; - -// @override -// Widget build(BuildContext context) { -// return TimelinePostOverview( -// timelineService: timelineService, -// options: TimelineOptions(), -// onTapCreatePost: (post) { -// Navigator.of(context).pushReplacement(MaterialPageRoute( -// builder: (context) => Titje(initialCategory: post.category))); -// }, -// ); -// } -// } diff --git a/packages/flutter_timeline/example/pubspec.yaml b/packages/flutter_timeline/example/pubspec.yaml index 73ee111..832242d 100644 --- a/packages/flutter_timeline/example/pubspec.yaml +++ b/packages/flutter_timeline/example/pubspec.yaml @@ -12,10 +12,7 @@ dependencies: flutter: sdk: flutter flutter_timeline: - git: - url: https://github.com/Iconica-Development/flutter_timeline - ref: 6.0.0 - path: packages/flutter_timeline + path: ../ intl: 0.19.0 dev_dependencies: flutter_lints: ^4.0.0 diff --git a/packages/flutter_timeline/lib/flutter_timeline.dart b/packages/flutter_timeline/lib/flutter_timeline.dart index 629152c..f587c76 100644 --- a/packages/flutter_timeline/lib/flutter_timeline.dart +++ b/packages/flutter_timeline/lib/flutter_timeline.dart @@ -1,10 +1,8 @@ -/// flutter_timeline library - // ignore_for_file: directives_ordering -library flutter_timeline; - /// userstory +library; + export "src/flutter_timeline_navigator_userstory.dart"; export "package:timeline_repository_interface/timeline_repository_interface.dart"; diff --git a/packages/flutter_timeline/lib/src/flutter_timeline_navigator_userstory.dart b/packages/flutter_timeline/lib/src/flutter_timeline_navigator_userstory.dart index ae717ca..fb68a2f 100644 --- a/packages/flutter_timeline/lib/src/flutter_timeline_navigator_userstory.dart +++ b/packages/flutter_timeline/lib/src/flutter_timeline_navigator_userstory.dart @@ -1,6 +1,5 @@ import "package:flutter/material.dart"; import "package:flutter_timeline/flutter_timeline.dart"; -import "package:timeline_repository_interface/timeline_repository_interface.dart"; class FlutterTimelineNavigatorUserstory extends StatefulWidget { const FlutterTimelineNavigatorUserstory({ @@ -38,20 +37,27 @@ class _FlutterTimelineNavigatorUserstoryState options: widget.options, onTapComments: (post) async { var currentUser = await timelineService.getCurrentUser(); - await _push(_timelinePostDetailScreenWidget(post, currentUser)); + + await widget.options.onTapComments?.call(post, currentUser) ?? + await _push(_timelinePostDetailScreenWidget(post, currentUser)); }, onTapCreatePost: () async { var selectedCategory = timelineService.getSelectedCategory(); - if (selectedCategory?.key != null) { - await _push(_timelineAddpostInformationScreenWidget()); + if (widget.options.onTapCreatePost != null) { + await widget.options.onTapCreatePost!(selectedCategory); } else { - await _push(_timelineChooseCategoryScreenWidget()); + if (selectedCategory?.key != null) { + await _push(_timelineAddpostInformationScreenWidget()); + } else { + await _push(_timelineChooseCategoryScreenWidget()); + } } }, onTapPost: (post) async { var currentUser = await timelineService.getCurrentUser(); if (context.mounted) - await _push(_timelinePostDetailScreenWidget(post, currentUser)); + await widget.options.onTapPost?.call(post, currentUser) ?? + await _push(_timelinePostDetailScreenWidget(post, currentUser)); }, ); @@ -71,7 +77,8 @@ class _FlutterTimelineNavigatorUserstoryState timelineService: timelineService, options: widget.options, ontapCategory: (category) async { - await _push(_timelineAddpostInformationScreenWidget()); + await widget.options.onTapCategory?.call(category) ?? + await _push(_timelineAddpostInformationScreenWidget()); }, ); @@ -80,7 +87,8 @@ class _FlutterTimelineNavigatorUserstoryState timelineService: timelineService, options: widget.options, onTapOverview: () async { - await _push(_timelinePostOverviewWidget()); + await widget.options.onTapOverview?.call() ?? + await _push(_timelinePostOverviewWidget()); }, ); @@ -88,12 +96,8 @@ class _FlutterTimelineNavigatorUserstoryState timelineService: timelineService, options: widget.options, onTapCreatePost: (post) async { - await Navigator.of(context).pushAndRemoveUntil( - MaterialPageRoute( - builder: (context) => _timelineScreenWidget(), - ), - (route) => route.isFirst, - ); + await widget.options.onTapCreatePostInOverview?.call(post) ?? + await _pushAndRemoveUntil(_timelineScreenWidget()); }, ); @@ -101,4 +105,11 @@ class _FlutterTimelineNavigatorUserstoryState await Navigator.of(context) .push(MaterialPageRoute(builder: (context) => screen)); } + + Future _pushAndRemoveUntil(Widget screen) async { + await Navigator.of(context).pushAndRemoveUntil( + MaterialPageRoute(builder: (context) => screen), + (route) => route.isFirst, + ); + } } diff --git a/packages/flutter_timeline/lib/src/models/timeline_options.dart b/packages/flutter_timeline/lib/src/models/timeline_options.dart index c3c5ac2..254b2ca 100644 --- a/packages/flutter_timeline/lib/src/models/timeline_options.dart +++ b/packages/flutter_timeline/lib/src/models/timeline_options.dart @@ -3,7 +3,6 @@ import "package:flutter/material.dart"; import "package:flutter_image_picker/flutter_image_picker.dart"; import "package:flutter_timeline/flutter_timeline.dart"; import "package:intl/intl.dart"; -import "package:timeline_repository_interface/timeline_repository_interface.dart"; class TimelineOptions { const TimelineOptions({ @@ -30,6 +29,12 @@ class TimelineOptions { this.timelineScreenDrawer, this.timelineScreenAppBarBuilder, this.onCreatePost, + this.onTapComments, + this.onTapCreatePost, + this.onTapPost, + this.onTapCategory, + this.onTapOverview, + this.onTapCreatePostInOverview, }); // Builders @@ -42,6 +47,12 @@ class TimelineOptions { //general final TimelineTranslations translations; + final Function(TimelinePost post, TimelineUser user)? onTapComments; + final Function(TimelineCategory? category)? onTapCreatePost; + final Function(TimelinePost post, TimelineUser user)? onTapPost; + final Function(TimelineCategory? category)? onTapCategory; + final Function()? onTapOverview; + final Function(TimelinePost post)? onTapCreatePostInOverview; // TimelinePostWidget final bool everyoneCanDelete; diff --git a/packages/flutter_timeline/lib/src/screens/timeline_add_post_information_screen.dart b/packages/flutter_timeline/lib/src/screens/timeline_add_post_information_screen.dart index 95f0546..355cabc 100644 --- a/packages/flutter_timeline/lib/src/screens/timeline_add_post_information_screen.dart +++ b/packages/flutter_timeline/lib/src/screens/timeline_add_post_information_screen.dart @@ -2,9 +2,6 @@ import "dart:typed_data"; import "package:flutter/material.dart"; import "package:flutter_timeline/flutter_timeline.dart"; -import "package:flutter_timeline/src/widgets/image_picker.dart"; -import "package:flutter_timeline/src/widgets/post_info_textfield.dart"; -import "package:timeline_repository_interface/timeline_repository_interface.dart"; class TimelineAddPostInformationScreen extends StatefulWidget { const TimelineAddPostInformationScreen({ diff --git a/packages/flutter_timeline/lib/src/screens/timeline_choose_category_screen.dart b/packages/flutter_timeline/lib/src/screens/timeline_choose_category_screen.dart index 7504831..3f23904 100644 --- a/packages/flutter_timeline/lib/src/screens/timeline_choose_category_screen.dart +++ b/packages/flutter_timeline/lib/src/screens/timeline_choose_category_screen.dart @@ -1,7 +1,5 @@ import "package:flutter/material.dart"; import "package:flutter_timeline/flutter_timeline.dart"; -import "package:flutter_timeline/src/widgets/post_info_textfield.dart"; -import "package:timeline_repository_interface/timeline_repository_interface.dart"; class TimelineChooseCategoryScreen extends StatelessWidget { const TimelineChooseCategoryScreen({ @@ -99,7 +97,8 @@ class TimelineChooseCategoryScreen extends StatelessWidget { title: newCategoryController.text, ), ); - Navigator.of(context).pop(); + if (context.mounted) + Navigator.of(context).pop(); }, ), ), diff --git a/packages/flutter_timeline/lib/src/screens/timeline_post_detail_screen.dart b/packages/flutter_timeline/lib/src/screens/timeline_post_detail_screen.dart index d0275c6..4866f45 100644 --- a/packages/flutter_timeline/lib/src/screens/timeline_post_detail_screen.dart +++ b/packages/flutter_timeline/lib/src/screens/timeline_post_detail_screen.dart @@ -1,9 +1,6 @@ import "package:flutter/material.dart"; import "package:flutter_svg/svg.dart"; import "package:flutter_timeline/flutter_timeline.dart"; -import "package:flutter_timeline/src/widgets/reaction_textfield.dart"; -import "package:flutter_timeline/src/widgets/timeline_post.dart"; -import "package:timeline_repository_interface/timeline_repository_interface.dart"; class TimelinePostDetailScreen extends StatefulWidget { const TimelinePostDetailScreen({ diff --git a/packages/flutter_timeline/lib/src/screens/timeline_post_overview.dart b/packages/flutter_timeline/lib/src/screens/timeline_post_overview.dart index 444c444..52c12e1 100644 --- a/packages/flutter_timeline/lib/src/screens/timeline_post_overview.dart +++ b/packages/flutter_timeline/lib/src/screens/timeline_post_overview.dart @@ -1,7 +1,5 @@ import "package:flutter/material.dart"; import "package:flutter_timeline/flutter_timeline.dart"; -import "package:flutter_timeline/src/widgets/timeline_post.dart"; -import "package:timeline_repository_interface/timeline_repository_interface.dart"; class TimelinePostOverview extends StatefulWidget { const TimelinePostOverview({ diff --git a/packages/flutter_timeline/lib/src/widgets/category_list.dart b/packages/flutter_timeline/lib/src/widgets/category_list.dart index 1abbacd..3aa3c81 100644 --- a/packages/flutter_timeline/lib/src/widgets/category_list.dart +++ b/packages/flutter_timeline/lib/src/widgets/category_list.dart @@ -1,7 +1,7 @@ +import "package:collection/collection.dart"; import "package:flutter/material.dart"; import "package:flutter_timeline/src/widgets/category_widget.dart"; import "package:timeline_repository_interface/timeline_repository_interface.dart"; -import "package:collection/collection.dart"; class CategoryList extends StatefulWidget { const CategoryList({ diff --git a/packages/flutter_timeline/lib/src/widgets/comment_section.dart b/packages/flutter_timeline/lib/src/widgets/comment_section.dart index 1867ac7..8b3df81 100644 --- a/packages/flutter_timeline/lib/src/widgets/comment_section.dart +++ b/packages/flutter_timeline/lib/src/widgets/comment_section.dart @@ -1,7 +1,6 @@ import "package:cached_network_image/cached_network_image.dart"; import "package:flutter/material.dart"; import "package:flutter_timeline/flutter_timeline.dart"; -import "package:timeline_repository_interface/timeline_repository_interface.dart"; class CommentSection extends StatefulWidget { const CommentSection({ diff --git a/packages/flutter_timeline/lib/src/widgets/post_list.dart b/packages/flutter_timeline/lib/src/widgets/post_list.dart index f4645b7..925adca 100644 --- a/packages/flutter_timeline/lib/src/widgets/post_list.dart +++ b/packages/flutter_timeline/lib/src/widgets/post_list.dart @@ -1,7 +1,5 @@ import "package:flutter/material.dart"; import "package:flutter_timeline/flutter_timeline.dart"; -import "package:flutter_timeline/src/widgets/timeline_post.dart"; -import "package:timeline_repository_interface/timeline_repository_interface.dart"; class PostList extends StatelessWidget { const PostList({ diff --git a/packages/flutter_timeline/lib/src/widgets/post_more_options_widget.dart b/packages/flutter_timeline/lib/src/widgets/post_more_options_widget.dart index 5262781..2e11a66 100644 --- a/packages/flutter_timeline/lib/src/widgets/post_more_options_widget.dart +++ b/packages/flutter_timeline/lib/src/widgets/post_more_options_widget.dart @@ -1,6 +1,5 @@ import "package:flutter/material.dart"; import "package:flutter_timeline/flutter_timeline.dart"; -import "package:timeline_repository_interface/timeline_repository_interface.dart"; class MoreOptionsButton extends StatelessWidget { const MoreOptionsButton({ diff --git a/packages/flutter_timeline/lib/src/widgets/reaction_textfield.dart b/packages/flutter_timeline/lib/src/widgets/reaction_textfield.dart index 988f5b4..f91e117 100644 --- a/packages/flutter_timeline/lib/src/widgets/reaction_textfield.dart +++ b/packages/flutter_timeline/lib/src/widgets/reaction_textfield.dart @@ -1,6 +1,5 @@ import "package:flutter/material.dart"; import "package:flutter_timeline/flutter_timeline.dart"; -import "package:timeline_repository_interface/timeline_repository_interface.dart"; class ReactionTextfield extends StatelessWidget { const ReactionTextfield({ diff --git a/packages/flutter_timeline/lib/src/widgets/timeline_post.dart b/packages/flutter_timeline/lib/src/widgets/timeline_post.dart index 838372a..d5afa16 100644 --- a/packages/flutter_timeline/lib/src/widgets/timeline_post.dart +++ b/packages/flutter_timeline/lib/src/widgets/timeline_post.dart @@ -1,10 +1,6 @@ import "package:cached_network_image/cached_network_image.dart"; import "package:flutter/material.dart"; import "package:flutter_timeline/flutter_timeline.dart"; -import "package:flutter_timeline/src/widgets/comment_section.dart"; -import "package:flutter_timeline/src/widgets/post_more_options_widget.dart"; -import "package:flutter_timeline/src/widgets/tappable_image.dart"; -import "package:timeline_repository_interface/timeline_repository_interface.dart"; class TimelinePostWidget extends StatefulWidget { const TimelinePostWidget({ diff --git a/packages/flutter_timeline/pubspec.yaml b/packages/flutter_timeline/pubspec.yaml index da082c7..574a43d 100644 --- a/packages/flutter_timeline/pubspec.yaml +++ b/packages/flutter_timeline/pubspec.yaml @@ -24,6 +24,7 @@ dependencies: intl: 0.19.0 flutter_svg: ^2.0.10+1 dotted_border: ^2.1.0 + collection: ^1.18.0 dev_dependencies: flutter_iconica_analysis: diff --git a/packages/timeline_repository_interface/lib/src/local/local_category_repository.dart b/packages/timeline_repository_interface/lib/src/local/local_category_repository.dart index 4f69ed8..825148f 100644 --- a/packages/timeline_repository_interface/lib/src/local/local_category_repository.dart +++ b/packages/timeline_repository_interface/lib/src/local/local_category_repository.dart @@ -10,7 +10,7 @@ class LocalCategoryRepository implements CategoryRepositoryInterface { TimelineCategory? _selectedCategory; @override - Future createCategory(TimelineCategory category) async{ + Future createCategory(TimelineCategory category) async { _categories.add(category); } diff --git a/packages/timeline_repository_interface/lib/src/local/local_post_repository.dart b/packages/timeline_repository_interface/lib/src/local/local_post_repository.dart index 26c0f16..e61f8be 100644 --- a/packages/timeline_repository_interface/lib/src/local/local_post_repository.dart +++ b/packages/timeline_repository_interface/lib/src/local/local_post_repository.dart @@ -13,7 +13,7 @@ class LocalPostRepository implements PostRepositoryInterface { final StreamController> _postsController = BehaviorSubject>(); - TimelinePost? _currentPost; + late TimelinePost? _currentPost; final jane = const TimelineUser( userId: "1", diff --git a/packages/timeline_repository_interface/lib/src/local/local_timeline_user_repository.dart b/packages/timeline_repository_interface/lib/src/local/local_timeline_user_repository.dart index bb22284..3b2853c 100644 --- a/packages/timeline_repository_interface/lib/src/local/local_timeline_user_repository.dart +++ b/packages/timeline_repository_interface/lib/src/local/local_timeline_user_repository.dart @@ -1,3 +1,4 @@ +import "package:collection/collection.dart"; import "package:timeline_repository_interface/src/interfaces/timeline_user_repository_interface.dart"; import "package:timeline_repository_interface/src/models/timeline_user.dart"; @@ -31,7 +32,7 @@ class LocalTimelineUserRepository implements TimelineUserRepositoryInterface { @override Future getUser(String userId) { - // TODO: implement getUser - throw UnimplementedError(); + var user = _users.firstWhereOrNull((element) => element.userId == userId); + return Future.value(user); } } diff --git a/packages/timeline_repository_interface/lib/src/services/timeline_service.dart b/packages/timeline_repository_interface/lib/src/services/timeline_service.dart index 5a04320..5e34d0b 100644 --- a/packages/timeline_repository_interface/lib/src/services/timeline_service.dart +++ b/packages/timeline_repository_interface/lib/src/services/timeline_service.dart @@ -1,5 +1,4 @@ import "dart:typed_data"; -import "package:timeline_repository_interface/src/local/local_timeline_user_repository.dart"; import "package:timeline_repository_interface/timeline_repository_interface.dart"; class TimelineService { diff --git a/packages/timeline_repository_interface/pubspec.yaml b/packages/timeline_repository_interface/pubspec.yaml index a60766d..fc0700b 100644 --- a/packages/timeline_repository_interface/pubspec.yaml +++ b/packages/timeline_repository_interface/pubspec.yaml @@ -11,6 +11,7 @@ dependencies: flutter: sdk: flutter rxdart: any + collection: ^1.18.0 dev_dependencies: flutter_iconica_analysis: