diff --git a/.gitignore b/.gitignore index 69548e3c..4e72ff99 100644 --- a/.gitignore +++ b/.gitignore @@ -49,4 +49,5 @@ app.*.map.json /coverage/ # Pubspec.lock -pubspec.lock \ No newline at end of file +pubspec.lock +doc/Functional Documentation.rar diff --git a/doc/api.zip b/doc/api.zip deleted file mode 100644 index cc521814..00000000 Binary files a/doc/api.zip and /dev/null differ diff --git a/lib/components/AppBar/appbar.dart b/lib/components/AppBar/appbar.dart index aa816bf7..956c084c 100644 --- a/lib/components/AppBar/appbar.dart +++ b/lib/components/AppBar/appbar.dart @@ -2,21 +2,24 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:tweaxy/components/AppBar/tabbar.dart'; import 'package:tweaxy/constants.dart'; import 'package:tweaxy/services/temp_user.dart'; -import 'package:tweaxy/shared/keys/profile_keys.dart'; import 'package:tweaxy/cubits/Tweets/tweet_cubit.dart'; import 'package:tweaxy/shared/keys/home_page_keys.dart'; -class ApplicationBar extends StatelessWidget { +class ApplicationBar extends StatefulWidget { const ApplicationBar( {super.key, required this.isVisible, required this.tabController}); final bool isVisible; final TabController tabController; + @override + State createState() => _ApplicationBarState(); +} + +class _ApplicationBarState extends State { @override Widget build(BuildContext context) { return SliverAppBar( @@ -26,7 +29,7 @@ class ApplicationBar extends StatelessWidget { backgroundColor: Colors.transparent, centerTitle: true, title: IconButton( - key: new ValueKey(HomePageKeys.iconRefreshAppBar), + key: const ValueKey(HomePageKeys.iconRefreshAppBar), onPressed: () { //refresh BlocProvider.of(context).refresh(); @@ -46,7 +49,9 @@ class ApplicationBar extends StatelessWidget { leading: Padding( padding: const EdgeInsets.all(10.0), child: GestureDetector( - onTap: () { + onTap: () async { + await TempUser.userSetData(context, refresh: false); + setState(() {}); Scaffold.of(context).openDrawer(); }, child: CircleAvatar( @@ -57,8 +62,8 @@ class ApplicationBar extends StatelessWidget { ), ), bottom: CustomTabBar( - isVisible: isVisible, - tabController: tabController, + isVisible: widget.isVisible, + tabController: widget.tabController, ), ); } diff --git a/lib/components/BottomNavBar/icons/notification_icon.dart b/lib/components/BottomNavBar/icons/notification_icon.dart index b8ae12b4..dbac547f 100644 --- a/lib/components/BottomNavBar/icons/notification_icon.dart +++ b/lib/components/BottomNavBar/icons/notification_icon.dart @@ -1,12 +1,7 @@ -import 'dart:async'; -import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:tweaxy/constants.dart'; -import 'package:tweaxy/helpers/api.dart'; import 'package:tweaxy/services/get_unseen_notification_count.dart'; -import 'package:tweaxy/services/temp_user.dart'; class NotificationIcon extends StatefulWidget { const NotificationIcon({super.key, required this.selectedIndex}); diff --git a/lib/components/HomePage/MobileComponents/drawer_home_screen.dart b/lib/components/HomePage/MobileComponents/drawer_home_screen.dart index 3578e3cc..45dbaf5f 100644 --- a/lib/components/HomePage/MobileComponents/drawer_home_screen.dart +++ b/lib/components/HomePage/MobileComponents/drawer_home_screen.dart @@ -39,7 +39,7 @@ class CustomDrawer extends StatelessWidget { padding: EdgeInsets.only( left: screenWidth * 0.05, bottom: screenHeight * 0.07), child: GestureDetector( - key: new ValueKey(HomePageKeys.userInfoInDrawerClick), + key: const ValueKey(HomePageKeys.userInfoInDrawerClick), onTap: () { Navigator.push( context, @@ -55,7 +55,7 @@ class CustomDrawer extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: EdgeInsets.only(bottom: 10.0), + padding: const EdgeInsets.only(bottom: 10.0), child: UserImageForTweet( image: TempUser.image, userid: TempUser.id, @@ -63,7 +63,7 @@ class CustomDrawer extends StatelessWidget { ), ), Padding( - padding: EdgeInsets.only(bottom: 4.5), + padding: const EdgeInsets.only(bottom: 4.5), child: Text( TempUser.name, style: const TextStyle( @@ -91,7 +91,7 @@ class CustomDrawer extends StatelessWidget { ), const Divider(height: 7), CustomDrawerListTile( - key: new ValueKey(HomePageKeys.profileNavigatorInDrawer), + key: const ValueKey(HomePageKeys.profileNavigatorInDrawer), icon: AppIcon.profile, title: 'Profile', onTap: () { @@ -111,7 +111,7 @@ class CustomDrawer extends StatelessWidget { context, CustomPageRoute( direction: AxisDirection.left, - child: SettingsAndPrivacyView())); + child: const SettingsAndPrivacyView())); }, ), ], diff --git a/lib/components/HomePage/MobileComponents/homepage_mobile.dart b/lib/components/HomePage/MobileComponents/homepage_mobile.dart index 98b3d890..26392f31 100644 --- a/lib/components/HomePage/MobileComponents/homepage_mobile.dart +++ b/lib/components/HomePage/MobileComponents/homepage_mobile.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:tweaxy/components/AppBar/appbar.dart'; -import 'package:tweaxy/components/BottomNavBar/bottom_navigation_bar.dart'; import 'package:tweaxy/components/BottomNavBar/icons/home_icon.dart'; import 'package:tweaxy/components/BottomNavBar/icons/message_icon.dart'; import 'package:tweaxy/components/BottomNavBar/icons/notification_icon.dart'; @@ -10,9 +9,7 @@ import 'package:tweaxy/components/BottomNavBar/icons/search_icon.dart'; import 'package:tweaxy/components/HomePage/MobileComponents/drawer_home_screen.dart'; import 'package:tweaxy/components/HomePage/floating_action_button.dart'; import 'package:tweaxy/components/HomePage/homepage_body.dart'; -import 'package:tweaxy/constants.dart'; import 'package:tweaxy/components/chat/chat_floating_button.dart'; -import 'package:tweaxy/services/temp_user.dart'; import 'package:tweaxy/views/chat/get_conversations_view.dart'; import 'package:tweaxy/views/notifications/notification_screen.dart'; import 'package:tweaxy/views/trends/trending_screen.dart'; @@ -67,9 +64,9 @@ class _HomePage2State extends State controller: controller, isVisible: _isVisible, ), - TrendingScreen(), - NotificationScreen(), - GetConversationsView(), + const TrendingScreen(), + const NotificationScreen(), + const GetConversationsView(), ]; return BlocProvider( create: (context) => SidebarCubit(), @@ -82,7 +79,7 @@ class _HomePage2State extends State if (state is SidebarInitialState || state is SidebarHomeState) { return widgets[_selectedIndex]; } else if (state is SidebarProfileState) - return ProfileScreen( + return const ProfileScreen( id: '', text: '', ); @@ -92,7 +89,7 @@ class _HomePage2State extends State }, ), floatingActionButton: _selectedIndex == 3 - ? ChatFloatingButton() + ? const ChatFloatingButton() : Offstage(offstage: !_isVisible, child: const FloatingButton()), bottomNavigationBar: Offstage( offstage: !_isVisible, @@ -121,7 +118,7 @@ class _HomePage2State extends State //search icon BottomNavigationBarItem( icon: SearchIcon( - key: new ValueKey(HomePageKeys.navSearchIcon), + key: const ValueKey(HomePageKeys.navSearchIcon), selectedIndex: _selectedIndex, ), label: ''), @@ -163,8 +160,7 @@ class HomeTweetsMobile extends StatelessWidget { final bool isVisible; @override Widget build(BuildContext context) { - TempUser.userSetData(context); - + return NestedScrollView( physics: const BouncingScrollPhysics(), controller: controller, @@ -180,7 +176,7 @@ class HomeTweetsMobile extends StatelessWidget { ) ]; }, - body: CustomScrollView(slivers: [ + body: const CustomScrollView(slivers: [ HomePageBody(), ])); } diff --git a/lib/components/HomePage/SharedComponents/account_information.dart b/lib/components/HomePage/SharedComponents/account_information.dart index 86c98d4a..f83d8f8a 100644 --- a/lib/components/HomePage/SharedComponents/account_information.dart +++ b/lib/components/HomePage/SharedComponents/account_information.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_linkify/flutter_linkify.dart'; import 'package:intl/intl.dart'; -import 'package:tweaxy/constants.dart'; import 'package:tweaxy/cubits/sidebar_cubit/sidebar_cubit.dart'; import 'package:tweaxy/cubits/sidebar_cubit/sidebar_states.dart'; import 'package:tweaxy/views/followersAndFollowing/followers.dart'; diff --git a/lib/components/HomePage/SharedComponents/user_image_for_tweet.dart b/lib/components/HomePage/SharedComponents/user_image_for_tweet.dart index a36640ce..f9fc7592 100644 --- a/lib/components/HomePage/SharedComponents/user_image_for_tweet.dart +++ b/lib/components/HomePage/SharedComponents/user_image_for_tweet.dart @@ -19,7 +19,6 @@ class UserImageForTweet extends StatelessWidget { // @override Widget build(BuildContext context) { - return GestureDetector( onTap: () { if (!kIsWeb) { @@ -27,14 +26,14 @@ class UserImageForTweet extends StatelessWidget { context, MaterialPageRoute( builder: (context) => ProfileScreen( - id: userid == TempUser.id ? '' : userid , + id: userid == TempUser.id ? '' : userid, text: userid == TempUser.id ? '' : 'no', ), ), ); } else { BlocProvider.of(context) - .openProfile(userid == TempUser.id ? '' : 'Following', userid == TempUser.id ? '' : 'Following'); + .openProfile(userid, userid == TempUser.id ? '' : 'Following'); } }, child: ClipRRect( diff --git a/lib/components/HomePage/Tweet/Delete Tweet/delete_alert_dialog.dart b/lib/components/HomePage/Tweet/Delete Tweet/delete_alert_dialog.dart index 46ea752e..e1de4619 100644 --- a/lib/components/HomePage/Tweet/Delete Tweet/delete_alert_dialog.dart +++ b/lib/components/HomePage/Tweet/Delete Tweet/delete_alert_dialog.dart @@ -30,7 +30,7 @@ class DeleteAlertDialog extends StatelessWidget { 'This can\'t be undone and it will be removed from your profile, the timeline of any accounts that follow you, and from search results'), // Message which will be pop up on the screen actions: [ TextButton( - key: new ValueKey(DeleteTweetKeys.tweetCancelDeleteMobile), + key: const ValueKey(DeleteTweetKeys.tweetCancelDeleteMobile), style: ButtonStyle( overlayColor: MaterialStateProperty.all(Colors.transparent), ), @@ -41,7 +41,7 @@ class DeleteAlertDialog extends StatelessWidget { style: TextStyle(color: Colors.black, fontSize: 19)), ), TextButton( - key: new ValueKey(DeleteTweetKeys.tweetDeleteConfirmMobile), + key: const ValueKey(DeleteTweetKeys.tweetDeleteConfirmMobile), style: ButtonStyle( overlayColor: MaterialStateProperty.all(Colors.transparent), ), diff --git a/lib/components/HomePage/Tweet/Delete Tweet/delete_alert_dialog_web.dart b/lib/components/HomePage/Tweet/Delete Tweet/delete_alert_dialog_web.dart index 7de13b33..e6fe4a09 100644 --- a/lib/components/HomePage/Tweet/Delete Tweet/delete_alert_dialog_web.dart +++ b/lib/components/HomePage/Tweet/Delete Tweet/delete_alert_dialog_web.dart @@ -1,13 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:oktoast/oktoast.dart'; -import 'package:tweaxy/components/HomePage/MobileComponents/homepage_mobile.dart'; import 'package:tweaxy/components/toasts/custom_web_toast.dart'; import 'package:tweaxy/cubits/Tweets/tweet_cubit.dart'; -import 'package:tweaxy/cubits/sidebar_cubit/sidebar_cubit.dart'; import 'package:tweaxy/services/tweets_services.dart'; import 'package:tweaxy/shared/keys/delete_tweet_keys.dart'; -import 'package:tweaxy/views/homepage.dart'; class DeleteAlertDialogWeb extends StatefulWidget { const DeleteAlertDialogWeb({super.key, required this.tweetId, required this.parentid}); @@ -47,7 +44,7 @@ class _DeleteAlertDialogWebState extends State { child: SizedBox( width: double.infinity, child: ElevatedButton( - key: new ValueKey(DeleteTweetKeys.tweetDeleteConfirmMobile), + key: const ValueKey(DeleteTweetKeys.tweetDeleteConfirmMobile), style: ElevatedButton.styleFrom( elevation: 0, @@ -69,10 +66,11 @@ class _DeleteAlertDialogWebState extends State { ), position: ToastPosition.bottom, duration: const Duration(seconds: 2)); - print("t state" + t.toString()); - if (t == "success") + print("t state$t"); + if (t == "success") { BlocProvider.of(context) .deleteTweet(tweetid: widget.tweetId, parentid: widget.parentid); + } }, child: const Text('Delete', @@ -85,7 +83,7 @@ class _DeleteAlertDialogWebState extends State { child: SizedBox( width: double.infinity, child: ElevatedButton( - key: new ValueKey(DeleteTweetKeys.tweetCancelDeleteMobile), + key: const ValueKey(DeleteTweetKeys.tweetCancelDeleteMobile), style: ElevatedButton.styleFrom( elevation: 0, side: const BorderSide( diff --git a/lib/components/HomePage/Tweet/Delete Tweet/tweet_settings_profile_web.dart b/lib/components/HomePage/Tweet/Delete Tweet/tweet_settings_profile_web.dart index 862cfa78..3738f767 100644 --- a/lib/components/HomePage/Tweet/Delete Tweet/tweet_settings_profile_web.dart +++ b/lib/components/HomePage/Tweet/Delete Tweet/tweet_settings_profile_web.dart @@ -35,12 +35,12 @@ class TweetSettingsProfileWeb extends StatelessWidget { }, itemBuilder: (BuildContext bc) { return [ - PopupMenuItem( + const PopupMenuItem( value: 'delete', child: Wrap( children: [ Icon( - key: new ValueKey( + key: ValueKey( DeleteTweetKeys.tweetSettingsMenuDeleteWeb), FontAwesomeIcons.trashCan, size: 20, @@ -59,8 +59,8 @@ class TweetSettingsProfileWeb extends StatelessWidget { ), ]; }, - icon: Icon( - key: new ValueKey(DeleteTweetKeys.tweetSettingsClickWeb), + icon: const Icon( + key: ValueKey(DeleteTweetKeys.tweetSettingsClickWeb), FontAwesomeIcons.ellipsis, size: 16, )); diff --git a/lib/components/HomePage/Tweet/Replies/interactions.dart b/lib/components/HomePage/Tweet/Replies/interactions.dart index 20d784a0..a9d67d2d 100644 --- a/lib/components/HomePage/Tweet/Replies/interactions.dart +++ b/lib/components/HomePage/Tweet/Replies/interactions.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -40,7 +42,7 @@ class InteractionReplyScreen extends StatelessWidget { key: const ValueKey(TweetKeys.repostInteractionRepliesScreen), isLiked: tweet.isUserRetweeted, bubblesSize: 0, - bubblesColor: BubblesColor( + bubblesColor: const BubblesColor( dotPrimaryColor: Colors.transparent, dotSecondaryColor: Colors.transparent, ), @@ -55,9 +57,9 @@ class InteractionReplyScreen extends StatelessWidget { await Future(() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); - token = await prefs.getString('token')!; + token = prefs.getString('token')!; }); - print(" the like value $isLiked"); + log(" the like value $isLiked"); if (isLiked) { var res = await TweetsServices.deleteRetweet(tweetid: tweet.id); BlocProvider.of(context).deleteretweet( @@ -84,7 +86,7 @@ class InteractionReplyScreen extends StatelessWidget { await Future(() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); - token = await prefs.getString('token')!; + token = prefs.getString('token')!; }); print(" the like value $isLiked"); if (isLiked) { diff --git a/lib/components/HomePage/Tweet/Replies/main_tweet_for_replies.dart b/lib/components/HomePage/Tweet/Replies/main_tweet_for_replies.dart index 8a9110ec..264f78ec 100644 --- a/lib/components/HomePage/Tweet/Replies/main_tweet_for_replies.dart +++ b/lib/components/HomePage/Tweet/Replies/main_tweet_for_replies.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:tweaxy/components/HomePage/SharedComponents/user_image_for_tweet.dart'; import 'package:tweaxy/components/HomePage/Tweet/Replies/interactions.dart'; @@ -38,22 +37,22 @@ class MainTweetReplies extends StatelessWidget { id: tweetid, ), builder: (context, snapshot) { - if (!snapshot.hasData) - return Center( + if (!snapshot.hasData) { + return const Center( child: CircularProgressIndicator(), ); - else { + } else { Tweet tweet = snapshot.data; List? t = tweet.image; List rawLines = []; if (tweet.tweetText != null) { rawLines = tweet.tweetText! - .split(new RegExp(r'(?<=#\w+)(?=\s)')) + .split(RegExp(r'(?<=#\w+)(?=\s)')) .expand((s) => s.split(RegExp(r'(?<=\S)(?=\s)'))) .toList(); } return Container( - decoration: BoxDecoration( + decoration: const BoxDecoration( color: Color.fromARGB(255, 253, 253, 255), ), child: Column( @@ -64,7 +63,7 @@ class MainTweetReplies extends StatelessWidget { reposteruserid: tweet.reposteruserid, reposteruserName: TempUser.name == reposteruserName ? ' You' - : ' ${reposteruserName}', + : ' $reposteruserName', ), Row( crossAxisAlignment: CrossAxisAlignment.start, @@ -86,17 +85,14 @@ class MainTweetReplies extends StatelessWidget { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - kIsWeb - ? User_TweetInfoWeb( - tweet: tweet, - ) - : UserTweetInfoReply( - tweet: tweet, - replyto: replyto, - ), + UserTweetInfoReply( + tweet: tweet, + replyto: replyto, + ), if (tweet.tweetText != null) Container( - padding: EdgeInsets.symmetric(vertical: 5), + padding: + const EdgeInsets.symmetric(vertical: 5), margin: const EdgeInsets.only( left: 2, right: 2, bottom: 3), child: RichText( @@ -113,7 +109,7 @@ class MainTweetReplies extends StatelessWidget { fontSize: 18, color: e.contains('#') ? Colors.blue - : Color.fromARGB( + : const Color.fromARGB( 255, 40, 39, 39)), ); }).toList(), @@ -178,7 +174,7 @@ class MainTweetReplies extends StatelessWidget { ), ), if (tweet.likesCount > 0 || tweet.retweetsCount > 0) - Divider( + const Divider( height: 1, color: Color.fromARGB(255, 153, 153, 153), ), @@ -228,12 +224,12 @@ class MainTweetReplies extends StatelessWidget { ], ), ), - Divider( + const Divider( height: 1, color: Color.fromARGB(255, 153, 153, 153), ), InteractionReplyScreen(tweet: tweet), - Divider( + const Divider( height: 1, color: Color.fromARGB(255, 153, 153, 153), ), diff --git a/lib/components/HomePage/Tweet/Replies/mute_block_reply.dart b/lib/components/HomePage/Tweet/Replies/mute_block_reply.dart index 5406b2bd..230c38a0 100644 --- a/lib/components/HomePage/Tweet/Replies/mute_block_reply.dart +++ b/lib/components/HomePage/Tweet/Replies/mute_block_reply.dart @@ -12,14 +12,14 @@ class MuteBlockReply extends StatelessWidget { return Padding( padding: const EdgeInsets.symmetric(horizontal: 25.0, vertical: 10), child: Container( - padding: EdgeInsets.symmetric(horizontal: 20, vertical: 9), + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 9), decoration: BoxDecoration( - color: Color.fromARGB(255, 236, 236, 236), + color: const Color.fromARGB(255, 236, 236, 236), border: Border.all( width: 1, color: const Color.fromARGB(255, 201, 200, 200), ), - borderRadius: BorderRadius.all(Radius.circular(6))), + borderRadius: const BorderRadius.all(Radius.circular(6))), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -29,7 +29,7 @@ class MuteBlockReply extends StatelessWidget { isMute ? 'This Post is from an \naccount you muted.' : 'This Post is from an \naccount you blocked.', - style: TextStyle( + style: const TextStyle( fontSize: 20, color: Color.fromARGB(255, 69, 68, 68), fontWeight: FontWeight.w400, @@ -44,7 +44,7 @@ class MuteBlockReply extends StatelessWidget { BlocProvider.of(context) .showTweet(tweetid); }, - child: Text( + child: const Text( 'View', style: TextStyle( fontSize: 21, diff --git a/lib/components/HomePage/Tweet/Replies/replies_list.dart b/lib/components/HomePage/Tweet/Replies/replies_list.dart index d19ad6a1..98754de4 100644 --- a/lib/components/HomePage/Tweet/Replies/replies_list.dart +++ b/lib/components/HomePage/Tweet/Replies/replies_list.dart @@ -46,7 +46,7 @@ class _MyPageState extends State { try { final List newItems = await TweetsServices.getReplies( offset: pageKey, id: widget.mainTweetId); - print('neew' + newItems.toString()); + print('neew$newItems'); final isLastPage = newItems.length < _pageSize; // print('tttt'); // print(newItems.length); @@ -69,7 +69,7 @@ class _MyPageState extends State { builder: (context, updateallstate) { return BlocBuilder( builder: (context, state) { - updateStatesforTweet(state, context, _pagingController); + updateStatesforTweet(state, context, _pagingController,isforHome: true); return PagedSliverList( pagingController: _pagingController, @@ -107,7 +107,7 @@ class _MyPageState extends State { ? 150 : 0), child: _pagingController.itemList != null && - _pagingController.itemList!.length > 0 && + _pagingController.itemList!.isNotEmpty && !item.isShown ? MuteBlockReply( tweetid: item.id, diff --git a/lib/components/HomePage/Tweet/Replies/replies_screen.dart b/lib/components/HomePage/Tweet/Replies/replies_screen.dart index 89a5d92e..3bd830ce 100644 --- a/lib/components/HomePage/Tweet/Replies/replies_screen.dart +++ b/lib/components/HomePage/Tweet/Replies/replies_screen.dart @@ -6,11 +6,12 @@ import 'package:tweaxy/components/add_tweet/custom_add_tweet_button.dart'; import 'package:tweaxy/components/custom_circular_progress_indicator.dart'; import 'package:tweaxy/cubits/Tweets/tweet_cubit.dart'; import 'package:tweaxy/cubits/Tweets/tweet_states.dart'; +import 'package:tweaxy/cubits/sidebar_cubit/sidebar_cubit.dart'; import 'package:tweaxy/models/app_icons.dart'; -import 'package:tweaxy/models/tweet.dart'; import 'package:tweaxy/services/temp_user.dart'; import 'package:tweaxy/shared/keys/add_reply_keys.dart'; import 'package:tweaxy/views/add_tweet/add_tweet_view.dart'; +import 'package:flutter/foundation.dart' show kIsWeb; class RepliesScreen extends StatefulWidget { const RepliesScreen( @@ -54,7 +55,7 @@ class _RepliesScreenState extends State { @override Widget build(BuildContext context) { - List replytochild = new List.from(widget.replyto); + List replytochild = List.from(widget.replyto); replytochild.add(widget.userHandle); return BlocBuilder( builder: (context, state) { @@ -68,7 +69,15 @@ class _RepliesScreenState extends State { appBar: AppBar( backgroundColor: Colors.white, elevation: 0.5, - leading: const BackButton(color: Colors.black), + leading: BackButton( + color: Colors.black, + onPressed: () { + if (kIsWeb) + BlocProvider.of(context).toggleMenu(0); + else + Navigator.pop(context); + }, + ), title: const Text( 'Post', style: TextStyle(color: Colors.black), @@ -88,7 +97,7 @@ class _RepliesScreenState extends State { reposteruserName: widget.reposteruserName, )), RepliesList( - replyto: replytochild as List, + replyto: replytochild, mainTweetId: widget.tweetid, ) ], diff --git a/lib/components/HomePage/Tweet/Replies/text_reply_info.dart b/lib/components/HomePage/Tweet/Replies/text_reply_info.dart index e10b61f8..9ab25349 100644 --- a/lib/components/HomePage/Tweet/Replies/text_reply_info.dart +++ b/lib/components/HomePage/Tweet/Replies/text_reply_info.dart @@ -8,7 +8,7 @@ class TextReplyInfo extends StatelessWidget { Widget build(BuildContext context) { return RichText( text: TextSpan( - text: count + ' ', + text: '$count ', style: const TextStyle( fontSize: 17.5, color: Colors.black, @@ -17,7 +17,7 @@ class TextReplyInfo extends StatelessWidget { children: [ TextSpan( text: text, - style: TextStyle( + style: const TextStyle( color: Color.fromARGB(255, 108, 108, 108), fontWeight: FontWeight.w400, ), diff --git a/lib/components/HomePage/Tweet/Replies/user_tweet_info_main_reply.dart b/lib/components/HomePage/Tweet/Replies/user_tweet_info_main_reply.dart index 0cf73cf6..b6b799c1 100644 --- a/lib/components/HomePage/Tweet/Replies/user_tweet_info_main_reply.dart +++ b/lib/components/HomePage/Tweet/Replies/user_tweet_info_main_reply.dart @@ -2,19 +2,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:tweaxy/components/HomePage/Tweet/TweetSettings/wrap_modal_bottom_profile.dart'; -import 'package:tweaxy/components/custom_button.dart'; import 'package:tweaxy/cubits/edit_profile_cubit/edit_profile_cubit.dart'; -import 'package:tweaxy/cubits/edit_profile_cubit/edit_profile_states.dart'; -import 'package:tweaxy/cubits/updata/updata_cubit.dart'; -import 'package:tweaxy/cubits/updata/updata_states.dart'; import 'package:tweaxy/models/tweet.dart'; import 'package:tweaxy/models/user.dart'; -import 'package:tweaxy/services/follow_user.dart'; import 'package:tweaxy/services/get_user_by_id.dart'; import 'package:tweaxy/services/temp_user.dart'; -import 'package:tweaxy/services/tweets_services.dart'; import 'package:tweaxy/shared/keys/tweet_keys.dart'; -import 'package:tweaxy/views/loading_screen.dart'; import 'package:tweaxy/views/profile/profile_screen.dart'; class UserTweetInfoReply extends StatefulWidget { @@ -43,16 +36,16 @@ class _UserTweetInfoReplyState extends State { builder: (context, snapshot) { if (!isFutureComplete) { // The future is not complete, show loading or an empty container - return Center( + return const Center( child: CircularProgressIndicator(), ); } - if (!snapshot.hasData) - return Center( + if (!snapshot.hasData) { + return const Center( child: CircularProgressIndicator(), ); - else { + } else { User user = snapshot.data!; String text = user.followedByMe! ? 'Following' @@ -97,7 +90,7 @@ class _UserTweetInfoReplyState extends State { // tweet.userName.trim().length <= 5 // ? '@${tweet.userHandle}' // : '${'@${tweet.userHandle.substring(0, 7)}'}...', - '${'@' + widget.tweet.userHandle.toString()}', + '@${widget.tweet.userHandle}', style: const TextStyle( overflow: TextOverflow.ellipsis, fontSize: 18, @@ -118,10 +111,11 @@ class _UserTweetInfoReplyState extends State { TweetKeys.followButtonRepliesScreen), forProfile: false, ), + IconButton( key: const ValueKey(TweetKeys.deleteTweetRepliesScreen), padding: EdgeInsets.zero, - constraints: BoxConstraints(), + constraints: const BoxConstraints(), icon: const Icon(FontAwesomeIcons.ellipsisVertical), color: const Color.fromARGB(255, 182, 182, 182), iconSize: 16, @@ -155,7 +149,7 @@ class _UserTweetInfoReplyState extends State { ) ], ), - widget.replyto.length > 0 + widget.replyto.isNotEmpty ? Padding( padding: const EdgeInsets.only(bottom: 8.0, right: 25), @@ -164,7 +158,7 @@ class _UserTweetInfoReplyState extends State { RichText( text: TextSpan( text: 'Replying to ', - style: TextStyle( + style: const TextStyle( fontSize: 18, color: Color.fromARGB(255, 108, 108, 108), fontWeight: FontWeight.w400, @@ -172,7 +166,7 @@ class _UserTweetInfoReplyState extends State { children: widget.replyto.asMap().entries.map((e) { return TextSpan( - text: '${'@' + e.value}', + text: '@${e.value}', style: const TextStyle( fontWeight: FontWeight.w400, fontSize: 18, diff --git a/lib/components/HomePage/Tweet/Tweet Options/block_user_from_tweet.dart b/lib/components/HomePage/Tweet/Tweet Options/block_user_from_tweet.dart index f0ddd46b..4c473ecf 100644 --- a/lib/components/HomePage/Tweet/Tweet Options/block_user_from_tweet.dart +++ b/lib/components/HomePage/Tweet/Tweet Options/block_user_from_tweet.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:tweaxy/cubits/Tweets/tweet_cubit.dart'; +import 'package:tweaxy/shared/keys/tweet_keys.dart'; import 'package:tweaxy/views/profile/profile_screen.dart'; class BlockUserTweet extends StatelessWidget { @@ -18,6 +19,7 @@ class BlockUserTweet extends StatelessWidget { @override Widget build(BuildContext context) { return ListTile( + key: new ValueKey(TweetKeys.blockUserFromTweet), onTap: () async { Navigator.pop(context); @@ -31,8 +33,7 @@ class BlockUserTweet extends StatelessWidget { context: context, builder: (context) => BlockUserDialog(username: userHandle), ); - BlocProvider.of(context) - .blockUser( userid); + BlocProvider.of(context).blockUser(userid); } }, leading: Icon( @@ -40,7 +41,7 @@ class BlockUserTweet extends StatelessWidget { color: Colors.blueGrey[600], ), title: Text( - isUserBlocked ? 'Unblock @${userHandle}' : 'Block @${userHandle}', + isUserBlocked ? 'Unblock @$userHandle' : 'Block @$userHandle', style: const TextStyle(fontSize: 20), ), ); diff --git a/lib/components/HomePage/Tweet/Tweet Options/follow_user_from_tweet.dart b/lib/components/HomePage/Tweet/Tweet Options/follow_user_from_tweet.dart index c0c0c7bb..611a48db 100644 --- a/lib/components/HomePage/Tweet/Tweet Options/follow_user_from_tweet.dart +++ b/lib/components/HomePage/Tweet/Tweet Options/follow_user_from_tweet.dart @@ -5,6 +5,7 @@ import 'package:tweaxy/cubits/Tweets/tweet_cubit.dart'; import 'package:tweaxy/services/follow_user.dart'; import 'package:tweaxy/cubits/edit_profile_cubit/edit_profile_cubit.dart'; import 'package:tweaxy/cubits/edit_profile_cubit/edit_profile_states.dart'; +import 'package:tweaxy/shared/keys/tweet_keys.dart'; class FollowUserTweet extends StatelessWidget { const FollowUserTweet( @@ -20,19 +21,21 @@ class FollowUserTweet extends StatelessWidget { @override Widget build(BuildContext context) { return ListTile( + key: new ValueKey(TweetKeys.followUserFromTweet), onTap: () async { BlocProvider.of(context) .emit(ProfilePageLoadingState()); if (isfollowedByMe) { await FollowUser.instance.deleteUser(userHandle); BlocProvider.of(context).unfollowUser(userid); - } else + } else { await FollowUser.instance.followUser(userHandle); + } Fluttertoast.showToast( msg: isfollowedByMe - ? 'You Unfollowed @${userHandle}' - : 'You followed @${userHandle}'); + ? 'You Unfollowed @$userHandle' + : 'You followed @$userHandle'); BlocProvider.of(context) .emit(ProfilePageCompletedState()); @@ -43,7 +46,7 @@ class FollowUserTweet extends StatelessWidget { color: Colors.blueGrey[600], ), title: Text( - isfollowedByMe ? 'Unfollow @${userHandle}' : 'follow @${userHandle}', + isfollowedByMe ? 'Unfollow @$userHandle' : 'follow @$userHandle', style: const TextStyle(fontSize: 20), ), ); diff --git a/lib/components/HomePage/Tweet/Tweet Options/mute_user_from_tweet.dart b/lib/components/HomePage/Tweet/Tweet Options/mute_user_from_tweet.dart index 5e552d74..28a38d78 100644 --- a/lib/components/HomePage/Tweet/Tweet Options/mute_user_from_tweet.dart +++ b/lib/components/HomePage/Tweet/Tweet Options/mute_user_from_tweet.dart @@ -5,6 +5,7 @@ import 'package:tweaxy/cubits/Tweets/tweet_cubit.dart'; import 'package:tweaxy/cubits/edit_profile_cubit/edit_profile_cubit.dart'; import 'package:tweaxy/cubits/edit_profile_cubit/edit_profile_states.dart'; import 'package:tweaxy/services/mute_user_service.dart'; +import 'package:tweaxy/shared/keys/tweet_keys.dart'; class MuteUserTweet extends StatelessWidget { MuteUserTweet( @@ -20,6 +21,8 @@ class MuteUserTweet extends StatelessWidget { @override Widget build(BuildContext context) { return ListTile( + key: new ValueKey(TweetKeys.muteUserFromTweet), + onTap: () async { BlocProvider.of(context) .emit(ProfilePageLoadingState()); @@ -65,7 +68,7 @@ class MuteUserTweet extends StatelessWidget { color: Colors.blueGrey[600], ), title: Text( - isMuted? 'Unmute @${userHandle}':'Mute @${userHandle}', + isMuted? 'Unmute @$userHandle':'Mute @$userHandle', style: const TextStyle(fontSize: 20), ), ); @@ -93,13 +96,13 @@ class MuteUserTweet extends StatelessWidget { duration: const Duration(seconds: 3), builder: ((context) { return Container( - padding: EdgeInsets.all(8), + padding: const EdgeInsets.all(8), decoration: BoxDecoration( color: failure ? Colors.red[100] : Colors.blue[100], border: Border.all( color: Colors.blue[700]!, ), - borderRadius: BorderRadius.all(Radius.circular(20))), + borderRadius: const BorderRadius.all(Radius.circular(20))), width: double.infinity, child: ListTile( title: Text( @@ -118,7 +121,7 @@ class MuteUserTweet extends StatelessWidget { icon: Icons.volume_off_outlined, muteFlag: false, mainContext: context, - userName: userHandle!, + userName: userHandle, ).show(context); isMuted = false; }, diff --git a/lib/components/HomePage/Tweet/TweetSettings/modal_bottom_options_posts.dart b/lib/components/HomePage/Tweet/TweetSettings/modal_bottom_options_posts.dart index 4969f41e..694456d3 100644 --- a/lib/components/HomePage/Tweet/TweetSettings/modal_bottom_options_posts.dart +++ b/lib/components/HomePage/Tweet/TweetSettings/modal_bottom_options_posts.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:tweaxy/components/HomePage/Tweet/Delete%20Tweet/delete_alert_dialog.dart'; import 'package:tweaxy/shared/keys/delete_tweet_keys.dart'; @@ -25,8 +24,8 @@ class ModalBottomProfilePosts extends StatelessWidget { ); }); }, - leading: Icon( - key: new ValueKey(DeleteTweetKeys.tweetSettingsMenuDeleteMobile), + leading: const Icon( + key: ValueKey(DeleteTweetKeys.tweetSettingsMenuDeleteMobile), FontAwesomeIcons.trashCan), title: const Text( 'Delete post', diff --git a/lib/components/HomePage/Tweet/TweetSettings/wrap_modal_bottom_profile.dart b/lib/components/HomePage/Tweet/TweetSettings/wrap_modal_bottom_profile.dart index f084f804..966b2f4d 100644 --- a/lib/components/HomePage/Tweet/TweetSettings/wrap_modal_bottom_profile.dart +++ b/lib/components/HomePage/Tweet/TweetSettings/wrap_modal_bottom_profile.dart @@ -1,8 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:tweaxy/components/HomePage/Tweet/Delete%20Tweet/delete_alert_dialog.dart'; import 'package:tweaxy/components/HomePage/Tweet/TweetSettings/modal_bottom_options_posts.dart'; -import 'package:tweaxy/shared/keys/delete_tweet_keys.dart'; class WrapModalBottomProfile extends StatelessWidget { const WrapModalBottomProfile({super.key, required this.tweetid, required this.forreply, required this.parentid}); diff --git a/lib/components/HomePage/Tweet/Video/basic_overlay.dart b/lib/components/HomePage/Tweet/Video/basic_overlay.dart index 91e0fa5b..62b1ca63 100644 --- a/lib/components/HomePage/Tweet/Video/basic_overlay.dart +++ b/lib/components/HomePage/Tweet/Video/basic_overlay.dart @@ -37,6 +37,6 @@ class BasicOverlayWidget extends StatelessWidget { : Container( alignment: Alignment.center, color: Colors.black26, - child: Icon(Icons.play_arrow, color: Colors.white, size: 80), + child: const Icon(Icons.play_arrow, color: Colors.white, size: 80), ); } diff --git a/lib/components/HomePage/Tweet/Video/multi_video.dart b/lib/components/HomePage/Tweet/Video/multi_video.dart index 465f01fe..38198c1a 100644 --- a/lib/components/HomePage/Tweet/Video/multi_video.dart +++ b/lib/components/HomePage/Tweet/Video/multi_video.dart @@ -1,12 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; -import 'package:multi_video_player/multi_video_player.dart'; import 'package:tweaxy/components/HomePage/Tweet/Video/full_video_screen.dart'; import 'package:tweaxy/components/HomePage/Tweet/Video/network_video_player.dart'; import 'package:tweaxy/components/transition/custom_page_route.dart'; class MultiVideo extends StatelessWidget { - MultiVideo({super.key, required this.videos}); + const MultiVideo({super.key, required this.videos}); final Listvideos; @override Widget build(BuildContext context) { diff --git a/lib/components/HomePage/Tweet/Video/network_video_player.dart b/lib/components/HomePage/Tweet/Video/network_video_player.dart index 971c8b57..df4170c4 100644 --- a/lib/components/HomePage/Tweet/Video/network_video_player.dart +++ b/lib/components/HomePage/Tweet/Video/network_video_player.dart @@ -1,6 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:tweaxy/components/HomePage/Tweet/Video/full_video_screen.dart'; -import 'package:tweaxy/components/transition/custom_page_route.dart'; import 'package:video_player/video_player.dart'; class NetworkVideoPlayer extends StatefulWidget { @@ -21,7 +19,7 @@ class _NetworkVideoPlayerState extends State { // ..addListener(() => setState(() {})) // ..setLooping(true) // ..initialize().then((_) => controller.play()); - controller..setLooping(false); + controller.setLooping(false); controller.initialize().then((_) { // Adding the initialized controller to the list diff --git a/lib/components/HomePage/Tweet/Video/video_player_controller.dart b/lib/components/HomePage/Tweet/Video/video_player_controller.dart index df1d89b9..b89b928b 100644 --- a/lib/components/HomePage/Tweet/Video/video_player_controller.dart +++ b/lib/components/HomePage/Tweet/Video/video_player_controller.dart @@ -13,9 +13,9 @@ class VideoPlayerWidget extends StatelessWidget { @override Widget build(BuildContext context) => - controller != null && controller.value.isInitialized + controller.value.isInitialized ? Container(alignment: Alignment.topCenter, child: buildVideo()) - : Container( + : const SizedBox( height: 200, child: Center(child: CircularProgressIndicator()), ); diff --git a/lib/components/HomePage/Tweet/reposted.dart b/lib/components/HomePage/Tweet/reposted.dart index 41c012d9..63aaa3b6 100644 --- a/lib/components/HomePage/Tweet/reposted.dart +++ b/lib/components/HomePage/Tweet/reposted.dart @@ -38,7 +38,7 @@ class RepostedBy extends StatelessWidget { } }, child: Padding( - padding: EdgeInsets.only(top: 5.0, bottom: 3, left: 25), + padding: const EdgeInsets.only(top: 5.0, bottom: 3, left: 25), child: Row( children: [ const Icon(FontAwesomeIcons.retweet, @@ -47,7 +47,7 @@ class RepostedBy extends StatelessWidget { constraints: BoxConstraints(maxWidth: screenWidth * 0.5), child: Text( maxLines: 1, - ' ${reposteruserName}', + ' $reposteruserName', style: const TextStyle( overflow: TextOverflow.ellipsis, fontSize: 17, diff --git a/lib/components/HomePage/Tweet/tweet.dart b/lib/components/HomePage/Tweet/tweet.dart index fac94e84..53b45f78 100644 --- a/lib/components/HomePage/Tweet/tweet.dart +++ b/lib/components/HomePage/Tweet/tweet.dart @@ -1,40 +1,34 @@ -import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:tweaxy/components/HomePage/SharedComponents/user_image_for_tweet.dart'; import 'package:tweaxy/components/HomePage/Tweet/Replies/replies_screen.dart'; import 'package:tweaxy/components/HomePage/Tweet/Video/multi_video.dart'; -import 'package:tweaxy/components/HomePage/Tweet/Video/network_video_player.dart'; import 'package:tweaxy/components/HomePage/Tweet/reposted.dart'; import 'package:tweaxy/components/HomePage/Tweet/tweet_interactions_general.dart'; import 'package:tweaxy/components/HomePage/Tweet/tweet_media.dart'; import 'package:tweaxy/components/HomePage/Tweet/user_tweet_info.dart'; import 'package:tweaxy/components/HomePage/Tweet/user_tweet_info_web.dart'; import 'package:tweaxy/components/transition/custom_page_route.dart'; -import 'package:tweaxy/cubits/Tweets/tweet_cubit.dart'; -import 'package:tweaxy/cubits/Tweets/tweet_states.dart'; import 'package:tweaxy/cubits/sidebar_cubit/sidebar_cubit.dart'; import 'package:tweaxy/models/tweet.dart'; import 'package:flutter/foundation.dart' show kIsWeb; import 'package:tweaxy/services/temp_user.dart'; -import 'package:tweaxy/services/tweets_services.dart'; import 'package:tweaxy/shared/keys/tweet_keys.dart'; -import 'package:tweaxy/views/followersAndFollowing/likers_in_tweet.dart'; import 'package:tweaxy/shared/keys/home_page_keys.dart'; -import 'package:tweaxy/views/profile/profile_screen.dart'; class CustomTweet extends StatelessWidget { - const CustomTweet( + CustomTweet( {super.key, required this.tweet, required this.replyto, required this.isMuted, - required this.isUserBlocked}); + required this.isUserBlocked, + this.tobebold}); final List replyto; final Tweet tweet; final bool isMuted; final bool isUserBlocked; + String? tobebold = ''; @override Widget build(BuildContext context) { @@ -43,34 +37,39 @@ class CustomTweet extends StatelessWidget { List rawLines = []; if (tweet.tweetText != null) { rawLines = tweet.tweetText! - .split(new RegExp(r'(?<=#\w+)(?=\s)')) + .split(RegExp(r'(((?<=#\w+)(?=\s)) | {"$tobebold"} )')) .expand((s) => s.split(RegExp(r'(?<=\S)(?=\s)'))) .toList(); } List? t = tweet.image; - String? k = null; + String? k; if (t != null) k = t[0]; return GestureDetector( key: const ValueKey(TweetKeys.clickToShowRepliesScreen), onTap: () { - print('tapped'); - Navigator.push( - context, - CustomPageRoute( - child: RepliesScreen( - replyto: replyto, - tweetid: - tweet.id == tweet.parentid ? tweet.id : tweet.parentid, - userHandle: tweet.userHandle, - isARepost: tweet.isretweet, - reposteruserName: tweet.reposteruserName, - ), - direction: AxisDirection.left)); + if (kIsWeb) + BlocProvider.of(context).showReplies( + tweet.id == tweet.parentid ? tweet.id : tweet.parentid, + tweet.userHandle, + replyto); + else + Navigator.push( + context, + CustomPageRoute( + child: RepliesScreen( + replyto: replyto, + tweetid: + tweet.id == tweet.parentid ? tweet.id : tweet.parentid, + userHandle: tweet.userHandle, + isARepost: tweet.isretweet, + reposteruserName: tweet.reposteruserName, + ), + direction: AxisDirection.left)); }, child: Container( padding: const EdgeInsets.symmetric(horizontal: 7), decoration: BoxDecoration( - color: Color.fromARGB(255, 253, 253, 255), + color: const Color.fromARGB(255, 253, 253, 255), border: Border( bottom: BorderSide( width: 0.5, @@ -92,7 +91,7 @@ class CustomTweet extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - key: new ValueKey(HomePageKeys.userImageInTweetClick), + key: const ValueKey(HomePageKeys.userImageInTweetClick), margin: const EdgeInsets.only(left: 2, right: 7, top: 7), child: UserImageForTweet( userid: tweet.userId, @@ -108,6 +107,7 @@ class CustomTweet extends StatelessWidget { kIsWeb ? User_TweetInfoWeb( tweet: tweet, + replyto: replyto, ) : User_TweetInfo( tweet: tweet, @@ -117,7 +117,7 @@ class CustomTweet extends StatelessWidget { ), if (tweet.tweetText != null) Container( - padding: EdgeInsets.symmetric(vertical: 5), + padding: const EdgeInsets.symmetric(vertical: 5), margin: const EdgeInsets.only( left: 2, right: 2, bottom: 5), child: RichText( @@ -130,11 +130,15 @@ class CustomTweet extends StatelessWidget { return TextSpan( text: e, style: TextStyle( - fontWeight: FontWeight.w400, + fontWeight: tobebold != null && + e.contains(tobebold!) + ? FontWeight.bold + : FontWeight.w400, fontSize: 18, color: e.contains('#') ? Colors.blue - : Color.fromARGB(255, 40, 39, 39)), + : const Color.fromARGB( + 255, 40, 39, 39)), ); }).toList(), ))), diff --git a/lib/components/HomePage/Tweet/tweet_interactions_general.dart b/lib/components/HomePage/Tweet/tweet_interactions_general.dart index a11c468b..7f139e1e 100644 --- a/lib/components/HomePage/Tweet/tweet_interactions_general.dart +++ b/lib/components/HomePage/Tweet/tweet_interactions_general.dart @@ -3,9 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:like_button/like_button.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:tweaxy/components/HomePage/Tweet/Replies/modal_bottom_repost.dart'; import 'package:tweaxy/cubits/Tweets/tweet_cubit.dart'; -import 'package:tweaxy/cubits/Tweets/tweet_states.dart'; import 'package:tweaxy/models/app_icons.dart'; import 'package:tweaxy/services/like_tweet.dart'; import 'package:tweaxy/services/tweets_services.dart'; @@ -14,7 +12,7 @@ import 'package:tweaxy/shared/keys/tweet_keys.dart'; import 'package:tweaxy/utilities/tweets_utilities.dart'; class TweetInteractions extends StatefulWidget { - TweetInteractions({ + TweetInteractions({super.key, interactionskey, required this.id, required this.likesCount, @@ -68,7 +66,7 @@ class _TweetInteractionsState extends State { children: [ IconButton( key: const ValueKey(TweetKeys.replyInteraction), - constraints: BoxConstraints(), + constraints: const BoxConstraints(), padding: EdgeInsets.zero, icon: const Padding( padding: EdgeInsets.only(bottom: 15.0), @@ -109,7 +107,7 @@ class _TweetInteractionsState extends State { await Future(() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); - token = await prefs.getString('token')!; + token = prefs.getString('token')!; }); print(" the like value $isLiked"); if (isLiked) { @@ -141,7 +139,7 @@ class _TweetInteractionsState extends State { await Future(() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); - token = await prefs.getString('token')!; + token = prefs.getString('token')!; }); print(" the like value $isLiked"); if (isLiked) { diff --git a/lib/components/HomePage/Tweet/tweet_media.dart b/lib/components/HomePage/Tweet/tweet_media.dart index ca91f7a5..d339419e 100644 --- a/lib/components/HomePage/Tweet/tweet_media.dart +++ b/lib/components/HomePage/Tweet/tweet_media.dart @@ -1,11 +1,6 @@ -import 'dart:async'; -import 'dart:io'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:multi_image_layout/multi_image_layout.dart'; -import 'package:video_player/video_player.dart'; class TweetMedia extends StatefulWidget { const TweetMedia({super.key, required this.pickedfiles}); diff --git a/lib/components/HomePage/Tweet/user_tweet_info.dart b/lib/components/HomePage/Tweet/user_tweet_info.dart index 6f41330c..97836161 100644 --- a/lib/components/HomePage/Tweet/user_tweet_info.dart +++ b/lib/components/HomePage/Tweet/user_tweet_info.dart @@ -1,23 +1,15 @@ -import 'package:animated_snack_bar/animated_snack_bar.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:fluttertoast/fluttertoast.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:oktoast/oktoast.dart'; -import 'package:shared_preferences/shared_preferences.dart'; import 'package:tweaxy/components/HomePage/Tweet/Tweet%20Options/block_user_from_tweet.dart'; import 'package:tweaxy/components/HomePage/Tweet/Tweet%20Options/follow_user_from_tweet.dart'; import 'package:tweaxy/components/HomePage/Tweet/Tweet%20Options/mute_user_from_tweet.dart'; import 'package:tweaxy/components/HomePage/Tweet/TweetSettings/wrap_modal_bottom_profile.dart'; -import 'package:tweaxy/components/toasts/custom_toast.dart'; -import 'package:tweaxy/cubits/Tweets/tweet_cubit.dart'; import 'package:tweaxy/models/tweet.dart'; import 'package:tweaxy/models/user.dart'; -import 'package:tweaxy/services/blocking_user_service.dart'; -import 'package:tweaxy/services/follow_user.dart'; import 'package:tweaxy/services/get_user_by_id.dart'; import 'package:tweaxy/services/temp_user.dart'; import 'package:tweaxy/shared/keys/delete_tweet_keys.dart'; +import 'package:tweaxy/shared/keys/tweet_keys.dart'; import 'package:tweaxy/shared/utils.dart'; class User_TweetInfo extends StatelessWidget { @@ -66,7 +58,7 @@ class User_TweetInfo extends StatelessWidget { // tweet.userName.trim().length <= 5 // ? '@${tweet.userHandle}' // : '${'@${tweet.userHandle.substring(0, 7)}'}...', - '${'@' + tweet.userHandle.toString()}', + '@${tweet.userHandle}', style: const TextStyle( overflow: TextOverflow.ellipsis, fontSize: 18, @@ -77,7 +69,7 @@ class User_TweetInfo extends StatelessWidget { ), ), Padding( - padding: EdgeInsets.only(top: 10), + padding: const EdgeInsets.only(top: 10), child: Container( margin: const EdgeInsets.symmetric(horizontal: 3.0), width: 3, @@ -104,10 +96,10 @@ class User_TweetInfo extends StatelessWidget { alignment: Alignment.topRight, child: IconButton( padding: EdgeInsets.zero, - constraints: BoxConstraints(), + constraints: const BoxConstraints(), key: ValueKey((Utils()).hashText( DeleteTweetKeys.tweetSettingsClickMobile + - (tweet.tweetText == null ? '' : tweet.tweetText) + (tweet.tweetText ?? '') .toString() + tweet.userHandle.toString())), icon: const Icon(FontAwesomeIcons.ellipsisVertical), @@ -186,7 +178,7 @@ class User_TweetInfo extends StatelessWidget { ], ), ), - replyto.length > 0 + replyto.isNotEmpty ? Padding( padding: const EdgeInsets.only(bottom: 8.0, right: 25), child: Wrap( @@ -194,14 +186,14 @@ class User_TweetInfo extends StatelessWidget { RichText( text: TextSpan( text: 'Replying to ', - style: TextStyle( + style: const TextStyle( fontSize: 18, color: Color.fromARGB(255, 108, 108, 108), fontWeight: FontWeight.w400, ), children: replyto.asMap().entries.map((e) { return TextSpan( - text: '${'@' + e.value}', + text: '@${e.value}', style: const TextStyle( fontWeight: FontWeight.w400, fontSize: 18, diff --git a/lib/components/HomePage/Tweet/user_tweet_info_web.dart b/lib/components/HomePage/Tweet/user_tweet_info_web.dart index 3adb3e30..ac1d2386 100644 --- a/lib/components/HomePage/Tweet/user_tweet_info_web.dart +++ b/lib/components/HomePage/Tweet/user_tweet_info_web.dart @@ -7,81 +7,153 @@ import 'package:tweaxy/shared/keys/delete_tweet_keys.dart'; class User_TweetInfoWeb extends StatelessWidget { const User_TweetInfoWeb( - {super.key, required this.tweet}); + {super.key, required this.tweet, required this.replyto}); final Tweet tweet; + final List replyto; + @override Widget build(BuildContext context) { - return Row( - mainAxisSize: MainAxisSize.max, + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Flexible( - child: Padding( - padding: const EdgeInsets.all(1.0), - child: Text( - tweet.userName, - style: const TextStyle( - overflow: TextOverflow.ellipsis, - fontWeight: FontWeight.bold, - fontSize: 18, - ), - ), - ), - ), - Flexible( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 3.0), - child: Text( - // tweet.userName.length <= 9 - // ? '@${tweet.userHandle}' - // : '${'@${tweet.userHandle.substring(0, 8)}'}...', - '@${tweet.userHandle}', - style: const TextStyle( - overflow: TextOverflow.ellipsis, - fontSize: 18, - ), - ), - ), - ), - Center( - child: Container( - margin: const EdgeInsets.symmetric(horizontal: 3.0), - width: 3, - height: 3, - decoration: const BoxDecoration( - color: Color.fromARGB(255, 133, 132, 132), - shape: BoxShape.circle, - ), - ), - ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 3.0), - child: Text( - tweet.time, - style: const TextStyle( - fontSize: 18, - ), + padding: const EdgeInsets.only( + top: 12.0, ), - ), - Spacer(), - Container( - alignment: Alignment.bottomRight, - child: Container( - child: ( tweet.userId == TempUser.id) - ? TweetSettingsProfileWeb( - tweetId: tweet.id, parentid: tweet.parentid, - ) - : IconButton( - key: new ValueKey(DeleteTweetKeys.tweetSettingsClickWeb), - splashRadius: 15, - hoverColor: const Color.fromARGB(255, 207, 232, 253), - icon: const Icon(FontAwesomeIcons.ellipsis), - iconSize: 16, - onPressed: () { - // if (isProfile) - }, + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Flexible( + child: Padding( + padding: const EdgeInsets.all(1.0), + child: Text( + tweet.userName, + style: const TextStyle( + overflow: TextOverflow.ellipsis, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), + ), + ), + Flexible( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 3.0), + child: Text( + // tweet.userName.length <= 9 + // ? '@${tweet.userHandle}' + // : '${'@${tweet.userHandle.substring(0, 8)}'}...', + '@${tweet.userHandle}', + style: const TextStyle( + overflow: TextOverflow.ellipsis, + fontSize: 18, + ), ), + ), + ), + Center( + child: Container( + margin: const EdgeInsets.symmetric(horizontal: 3.0), + width: 3, + height: 3, + decoration: const BoxDecoration( + color: Color.fromARGB(255, 133, 132, 132), + shape: BoxShape.circle, + ), + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 3.0), + child: Text( + tweet.time, + style: const TextStyle( + fontSize: 18, + ), + ), + ), + const Spacer(), + Container( + alignment: Alignment.bottomRight, + child: Container( + child: (tweet.userId == + TempUser + .id && //my post and not retweet or my post and my retweet + (!tweet.isretweet || + tweet.userId == tweet.reposteruserid)) + ? TweetSettingsProfileWeb( + tweetId: tweet.id, + parentid: tweet.parentid, + ) + : IconButton( + key: const ValueKey( + DeleteTweetKeys.tweetSettingsClickWeb), + splashRadius: 15, + hoverColor: const Color.fromARGB(255, 207, 232, 253), + icon: const Icon(FontAwesomeIcons.ellipsis), + iconSize: 16, + onPressed: () { + // if (isProfile) + }, + ), + ), + ) + ], ), - ) + ), + replyto.isNotEmpty + ? Padding( + padding: const EdgeInsets.only(bottom: 8.0, left: 0), + child: Wrap( + children: [ + RichText( + text: TextSpan( + text: 'Replying to ', + style: const TextStyle( + fontSize: 18, + color: Color.fromARGB(255, 108, 108, 108), + fontWeight: FontWeight.w400, + ), + children: replyto.asMap().entries.map((e) { + return TextSpan( + text: '@${e.value}', + style: const TextStyle( + fontWeight: FontWeight.w400, + fontSize: 18, + color: Colors.blue), + children: [ + TextSpan( + text: (e.key != replyto.length - 1) + ? ' and ' + : '') + ]); + }).toList(), + )) + ], + ), + ) + : Container() + ], + ); + } + + Widget repliesNames() { + return Wrap( + children: [ + RichText( + text: TextSpan( + children: replyto.asMap().entries.map((e) { + return TextSpan( + text: e.toString(), + style: const TextStyle( + fontWeight: FontWeight.w400, + fontSize: 20, + color: Colors.blue), + children: [ + TextSpan(text: (e.key != replyto.length - 1) ? ' and ' : '') + ]); + }).toList(), + )) ], ); } diff --git a/lib/components/HomePage/WebComponents/SideBar/side_nav_bar.dart b/lib/components/HomePage/WebComponents/SideBar/side_nav_bar.dart index 78e22e57..eab8a16f 100644 --- a/lib/components/HomePage/WebComponents/SideBar/side_nav_bar.dart +++ b/lib/components/HomePage/WebComponents/SideBar/side_nav_bar.dart @@ -10,7 +10,6 @@ import 'package:tweaxy/components/HomePage/MobileComponents/custom_drawer_list_t import 'package:tweaxy/components/HomePage/SharedComponents/user_image_for_tweet.dart'; import 'package:tweaxy/components/HomePage/WebComponents/SideBar/post_button.dart'; import 'package:tweaxy/components/HomePage/WebComponents/SideBar/sidebar_text.dart'; -import 'package:tweaxy/constants.dart'; import 'package:tweaxy/cubits/sidebar_cubit/sidebar_cubit.dart'; import 'package:flutter/foundation.dart' show kIsWeb; import 'package:tweaxy/cubits/update_username_cubit/update_username_cubit.dart'; diff --git a/lib/components/HomePage/WebComponents/explore_web_screen.dart b/lib/components/HomePage/WebComponents/explore_web_screen.dart index 9c03b5ac..2896706f 100644 --- a/lib/components/HomePage/WebComponents/explore_web_screen.dart +++ b/lib/components/HomePage/WebComponents/explore_web_screen.dart @@ -1,18 +1,12 @@ import 'dart:developer'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_typeahead/flutter_typeahead.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:intl/intl.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:tweaxy/components/HomePage/WebComponents/search_bar_web.dart'; -import 'package:tweaxy/cubits/sidebar_cubit/sidebar_cubit.dart'; import 'package:tweaxy/models/trend.dart'; -import 'package:tweaxy/models/user.dart'; import 'package:tweaxy/services/get_trends.dart'; -import 'package:tweaxy/services/search_for_users.dart'; -import 'package:tweaxy/views/search_users/search_users.dart'; class ExploreWebScreen extends StatefulWidget { const ExploreWebScreen({super.key}); @@ -29,6 +23,7 @@ class _ExploreWebScreenState extends State { PagingController(firstPageKey: 0); final int _pageSize = 7; + @override void initState() { // TODO: implement initState super.initState(); diff --git a/lib/components/HomePage/WebComponents/homepage_web.dart b/lib/components/HomePage/WebComponents/homepage_web.dart index 05756cee..4efb6bd3 100644 --- a/lib/components/HomePage/WebComponents/homepage_web.dart +++ b/lib/components/HomePage/WebComponents/homepage_web.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:tweaxy/services/temp_user.dart'; +import 'package:tweaxy/components/HomePage/Tweet/Replies/replies_screen.dart'; import 'package:tweaxy/views/chat/web/get_conversations_web_view.dart'; import 'package:tweaxy/views/followersAndFollowing/web_followers_followings.dart'; import 'package:tweaxy/views/notifications/notification_screen.dart'; @@ -96,6 +96,16 @@ class _HomePageWebState extends State { id: state.id, text: state.text, )); + } else if (state is OpenRepliesState) { + return Expanded( + flex: 8, + child: RepliesScreen( + tweetid: state.tweetid, + replyto: state.replyto, + userHandle: state.userHandle, + isARepost: false, + reposteruserName: ''), + ); } else if (state is SearchUserLoadingState) { return const Scaffold( body: Center( @@ -243,7 +253,7 @@ class _HomeTweetsState extends State { SliverToBoxAdapter( child: isweb(), ), - HomePageBody() + const HomePageBody() ]), ])), ), @@ -255,7 +265,7 @@ Widget isweb() { if (kIsWeb) { return const AddPost(); } else { - return SizedBox( + return const SizedBox( height: 0, width: 0, ); diff --git a/lib/components/HomePage/WebComponents/profile_component_web.dart b/lib/components/HomePage/WebComponents/profile_component_web.dart index 9d27b559..705eee4b 100644 --- a/lib/components/HomePage/WebComponents/profile_component_web.dart +++ b/lib/components/HomePage/WebComponents/profile_component_web.dart @@ -1,7 +1,6 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:tweaxy/views/profile/likers_profile_view.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:tweaxy/components/HomePage/SharedComponents/account_information.dart'; import 'package:tweaxy/components/HomePage/SharedComponents/profile_icon_button.dart'; @@ -11,9 +10,9 @@ import 'package:tweaxy/cubits/edit_profile_cubit/edit_profile_states.dart'; import 'package:tweaxy/cubits/sidebar_cubit/sidebar_cubit.dart'; import 'package:tweaxy/cubits/sidebar_cubit/sidebar_states.dart'; import 'package:tweaxy/models/user.dart'; +import 'package:tweaxy/services/follow_user.dart'; import 'package:tweaxy/services/get_user_by_id.dart'; import 'package:tweaxy/views/profile/edit_profile_screen.dart'; -import 'package:tweaxy/components/Profile/profile_likes.dart'; import 'package:tweaxy/views/profile/profile_screen.dart'; import 'package:tweaxy/components/Profile/profile_screen_body.dart'; @@ -70,6 +69,7 @@ class _ProfileComponentWebState extends State _tabController.dispose(); super.dispose(); } + int _selectedTabIndex = 0; Color textColor = Colors.black; @@ -80,7 +80,7 @@ class _ProfileComponentWebState extends State int postsNumber = 678530; void Function() onPressed = () {}; int? selectedMenu; - bool initialized = false; + bool initialized = false; @override Widget build(BuildContext context) { @@ -101,7 +101,6 @@ class _ProfileComponentWebState extends State future: GetUserById.instance.getUserById(id), builder: (context, snapshot) { if (!snapshot.hasData) { - return const Scaffold( body: Center( child: CircularProgressIndicator( @@ -111,14 +110,15 @@ class _ProfileComponentWebState extends State ); } else { var user = snapshot.data!; - if (!initialized) { - initialized = true; - if (text != 'Edit Profile') { - text = user.followedByMe! ? 'Following' : 'Follow'; - } + if (text != 'Edit Profile') { + text = user.followedByMe! + ? 'Following' + : user.followsme! + ? 'Follow back' + : 'Follow'; } - postsNumber=user.interactionCount!; + postsNumber = user.interactionCount!; return Scaffold( appBar: AppBar( leading: IconButton( @@ -381,15 +381,18 @@ class _ProfileComponentWebState extends State } Widget _followEditButton(User user, BuildContext currContext) { - if (text == 'Follow') { + if (text == 'Follow' || text == 'Follow back') { textColor = Colors.white; buttonColor = Colors.black; borderWidth = 0; borderColor = Colors.transparent; - onPressed = () { + onPressed = () async { text = 'Following'; //TODO:- Implement the follow logic - setState(() {}); + await FollowUser.instance.followUser(user.userName!); + setState(() { + text = 'Following'; + }); }; } else if (text == 'Edit Profile') { textColor = Colors.black; @@ -417,10 +420,15 @@ class _ProfileComponentWebState extends State ); }; } else { - onPressed = () { + onPressed = () async { text = 'Follow'; //TODO:- Implement the unfollow logic - setState(() {}); + bool s = user.followsme!; + await FollowUser.instance.deleteUser(user.userName!); + + setState(() { + text = s ? 'Follow back' : 'Follow'; + }); }; if (hoverd) { text = 'Unfollow'; diff --git a/lib/components/HomePage/WebComponents/search_bar_web.dart b/lib/components/HomePage/WebComponents/search_bar_web.dart index 45fbe1f4..9a504409 100644 --- a/lib/components/HomePage/WebComponents/search_bar_web.dart +++ b/lib/components/HomePage/WebComponents/search_bar_web.dart @@ -34,7 +34,7 @@ class _SearchBarWebState extends State { decoration: InputDecoration( fillColor: Colors.grey[100], hoverColor: Colors.grey[100], - prefixIcon: Icon(Icons.search), + prefixIcon: const Icon(Icons.search), suffixIcon: cleared ? IconButton( onPressed: () { @@ -42,7 +42,7 @@ class _SearchBarWebState extends State { cleared = false; setState(() {}); }, - icon: Icon(Icons.close)) + icon: const Icon(Icons.close)) : null, focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(50), diff --git a/lib/components/HomePage/floating_action_button.dart b/lib/components/HomePage/floating_action_button.dart index ce5f47b8..6870bd6e 100644 --- a/lib/components/HomePage/floating_action_button.dart +++ b/lib/components/HomePage/floating_action_button.dart @@ -23,6 +23,7 @@ class FloatingButton extends StatelessWidget { key: const ValueKey(AddTweetKeys.addTweet), icon: Icons.add, activeIcon: Icons.close, + iconTheme: const IconThemeData(color: Colors.white), spacing: 3, // openCloseDial: isDialOpen, childPadding: const EdgeInsets.all(5), diff --git a/lib/components/HomePage/homepage_body.dart b/lib/components/HomePage/homepage_body.dart index cf888f0a..17136bd2 100644 --- a/lib/components/HomePage/homepage_body.dart +++ b/lib/components/HomePage/homepage_body.dart @@ -3,19 +3,12 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; -import 'package:shared_preferences/shared_preferences.dart'; import 'package:tweaxy/components/HomePage/Tweet/tweet.dart'; import 'package:tweaxy/cubits/Tweets/tweet_cubit.dart'; import 'package:tweaxy/cubits/Tweets/tweet_states.dart'; -import 'package:tweaxy/cubits/sidebar_cubit/sidebar_states.dart'; -import 'package:tweaxy/cubits/updata/updata_cubit.dart'; -import 'package:tweaxy/cubits/updata/updata_states.dart'; import 'package:tweaxy/cubits/update_username_cubit/update_username_cubit.dart'; import 'package:tweaxy/cubits/update_username_cubit/update_username_states.dart'; -import 'package:tweaxy/helpers/firebase_api.dart'; import 'package:tweaxy/models/tweet.dart'; -import 'package:tweaxy/services/send_device_token.dart'; -import 'package:tweaxy/services/temp_user.dart'; import 'package:tweaxy/services/tweets_services.dart'; import 'package:tweaxy/utilities/tweets_utilities.dart'; @@ -26,7 +19,7 @@ class HomePageBody extends StatefulWidget { } class _MyPageState extends State { - PagingController _pagingController = + final PagingController _pagingController = PagingController(firstPageKey: 0); @override @@ -50,7 +43,7 @@ class _MyPageState extends State { try { final List newItemstmp = await TweetsServices.getTweetsHome(offset: pageKey); - print('lllll' + newItemstmp.toString()); + print('lllll$newItemstmp'); // final ListnewItems=newItemstmp.map((e) {if(!_pagingController.itemList.contains(e)) // return e;}).toList(); final List newItems = []; @@ -84,52 +77,47 @@ class _MyPageState extends State { Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { - updateStatesforTweet(state, context, _pagingController); - return BlocBuilder( - builder: (context, updateallstate) { - return BlocBuilder( - builder: (context, state) { - updateStatesforTweet(state, context, _pagingController, - isforHome: true); - return PagedSliverList( - pagingController: _pagingController, - builderDelegate: PagedChildBuilderDelegate( - noItemsFoundIndicatorBuilder: (context) { - return const Padding( - padding: EdgeInsets.only(top: 30.0), - child: Column( - children: [ - Center( - child: Text( - "No tweets found\n", - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold), - ), - ), - Center( - child: Text( - "List is currently empty", - style: TextStyle( - fontSize: 18, - color: Color.fromRGBO(121, 119, 119, 1)), - ), - ), - ], + return BlocBuilder( + builder: (tweetContext, tweetState) { + updateStatesforTweet(tweetState, tweetContext, _pagingController, + isforHome: true); + return PagedSliverList( + pagingController: _pagingController, + builderDelegate: PagedChildBuilderDelegate( + noItemsFoundIndicatorBuilder: (context) { + return const Padding( + padding: EdgeInsets.only(top: 30.0), + child: Column( + children: [ + Center( + child: Text( + "No tweets found\n", + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold), + ), ), - ); - }, - animateTransitions: true, - itemBuilder: (context, item, index) { - return CustomTweet( - tweet: item, - replyto: const [], - isMuted: false, - isUserBlocked: false, - ); - }, - ), - ); - }, + Center( + child: Text( + "List is currently empty", + style: TextStyle( + fontSize: 18, + color: Color.fromRGBO(121, 119, 119, 1)), + ), + ), + ], + ), + ); + }, + animateTransitions: true, + itemBuilder: (context, item, index) { + return CustomTweet( + tweet: item, + replyto: const [], + isMuted: false, + isUserBlocked: false, + ); + }, + ), ); }, ); diff --git a/lib/components/Profile/posts_profile.dart b/lib/components/Profile/posts_profile.dart index 9524326c..c6d8824a 100644 --- a/lib/components/Profile/posts_profile.dart +++ b/lib/components/Profile/posts_profile.dart @@ -83,7 +83,7 @@ class _MyPageState extends State { itemBuilder: (context, item, index) { return CustomTweet( tweet: item, - replyto: [], isMuted: widget.isMuted, + replyto: const [], isMuted: widget.isMuted, isUserBlocked: widget.isUserBlocked, ); }, diff --git a/lib/components/Profile/profile_likes.dart b/lib/components/Profile/profile_likes.dart index df8ff804..e69cd67f 100644 --- a/lib/components/Profile/profile_likes.dart +++ b/lib/components/Profile/profile_likes.dart @@ -26,7 +26,7 @@ class ProfileLikes extends StatefulWidget { State createState() => _ProfileLikesState(); } -final _pageSize = 4; +const _pageSize = 4; class _ProfileLikesState extends State { GetLikersInProfile services = GetLikersInProfile(Dio()); @@ -61,7 +61,7 @@ class _ProfileLikesState extends State { } } - PagingController _pagingController = + final PagingController _pagingController = PagingController(firstPageKey: 0); @override Widget build(BuildContext context) { @@ -106,7 +106,7 @@ class _ProfileLikesState extends State { )), itemBuilder: (context, item, index) { return (_pagingController.itemList != null && - _pagingController.itemList!.length > 0 && + _pagingController.itemList!.isNotEmpty && !item.isShown) ? MuteBlockReply( tweetid: item.id, @@ -114,7 +114,7 @@ class _ProfileLikesState extends State { ) : CustomTweet( tweet: item, - replyto: [], + replyto: const [], isMuted: widget.isMuted, isUserBlocked: widget.isUserBlocked, ); diff --git a/lib/components/Profile/profile_screen_body.dart b/lib/components/Profile/profile_screen_body.dart index 3fa4af5d..d0e31951 100644 --- a/lib/components/Profile/profile_screen_body.dart +++ b/lib/components/Profile/profile_screen_body.dart @@ -1,8 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:tweaxy/components/HomePage/Tweet/tweet.dart'; -import 'package:tweaxy/models/tweet.dart'; -import 'package:tweaxy/services/tweets_services.dart'; -import 'package:tweaxy/utilities/tweets_utilities.dart'; import 'package:tweaxy/components/Profile/posts_profile.dart'; import 'package:tweaxy/components/Profile/profile_likes.dart'; @@ -101,7 +97,7 @@ class ProfileScreenBody extends StatelessWidget { @override Widget build(BuildContext context) { - print('dd'+id.toString()); + print('dd$id'); // List tweets = initializeTweets(temp); print('IsMuted = $isMuted'); return TabBarView( diff --git a/lib/components/add_tweet/custom_add_tweet_button.dart b/lib/components/add_tweet/custom_add_tweet_button.dart index 4f5bb38c..f7794b90 100644 --- a/lib/components/add_tweet/custom_add_tweet_button.dart +++ b/lib/components/add_tweet/custom_add_tweet_button.dart @@ -50,10 +50,12 @@ class CustomAddTweetButton extends StatelessWidget { showToastWidget(CustomToast(message: "the $type has been posted")); tweetcontent.text = ''; } - if (type == 'post') + if (type == 'post') { BlocProvider.of(context).addTweet(); - if (type == 'reply') + } + if (type == 'reply') { BlocProvider.of(context).addReply(); + } if (!forReplyScreen) Navigator.pop(context); } else { showToastWidget(CustomToast(message: "the $type cant be empty")); diff --git a/lib/components/chat/custom_chat_user.dart b/lib/components/chat/custom_chat_user.dart index 9acaf77d..ed20d30f 100644 --- a/lib/components/chat/custom_chat_user.dart +++ b/lib/components/chat/custom_chat_user.dart @@ -5,7 +5,6 @@ import 'package:tweaxy/components/transition/custom_page_route.dart'; import 'package:tweaxy/models/user_chat.dart'; import 'package:tweaxy/views/chat/chat_room.dart'; import 'package:tweaxy/constants.dart'; -import 'package:tweaxy/views/chat/web/chat_room_web.dart'; class CustomUserChat extends StatefulWidget { CustomUserChat({super.key, required this.user}); @@ -16,6 +15,7 @@ class CustomUserChat extends StatefulWidget { class _CustomFollowersState extends State { String id = '0'; + @override void initState() { super.initState(); // Future(() async { @@ -84,7 +84,7 @@ class _CustomFollowersState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - widget.user.name!, + widget.user.name, maxLines: 1, style: const TextStyle( fontWeight: FontWeight.bold, diff --git a/lib/components/chat/custom_chat_user_web.dart b/lib/components/chat/custom_chat_user_web.dart index 681a8b89..08dc0926 100644 --- a/lib/components/chat/custom_chat_user_web.dart +++ b/lib/components/chat/custom_chat_user_web.dart @@ -17,6 +17,7 @@ class CustomUserChatWeb extends StatefulWidget { class _CustomFollowersState extends State { String id = '0'; + @override void initState() { super.initState(); // Future(() async { @@ -91,7 +92,7 @@ class _CustomFollowersState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - widget.user.name!, + widget.user.name, maxLines: 1, style: const TextStyle( fontWeight: FontWeight.bold, diff --git a/lib/components/custom_button.dart b/lib/components/custom_button.dart index 7c3d617a..749083be 100644 --- a/lib/components/custom_button.dart +++ b/lib/components/custom_button.dart @@ -45,7 +45,9 @@ class _CustomButtonState extends State { fontWeight: FontWeight.w600, fontSize: widget.text == "Follow Back" || widget.text == 'Following' || - widget.text == 'Follow' + widget.text == 'Follow' || + widget.text == 'Blocked' || + widget.text == 'Blocked you' ? 16 : 20), ), diff --git a/lib/components/custom_followers.dart b/lib/components/custom_followers.dart index ecddaa43..5e2aca72 100644 --- a/lib/components/custom_followers.dart +++ b/lib/components/custom_followers.dart @@ -20,6 +20,7 @@ class CustomFollowers extends StatefulWidget { class _CustomFollowersState extends State { String id = '0'; + @override void initState() { super.initState(); Future(() async { @@ -173,18 +174,18 @@ class _CustomFollowersState extends State { // width: 140, // height: 45, child: CustomButton( - color: (widget.user.blocksMe! || - widget.user.blockedByMe!) + color: (widget.user.blocksMe || + widget.user.blockedByMe) ? Colors.red : !widget.user.followedByMe ? Colors.black : Colors.white, text: getText(), onPressedCallback: () async { - if (widget.user.blockedByMe!) { + if (widget.user.blockedByMe) { bool status = await BlockingUserService.unBlockUser( - username: widget.user.username!, + username: widget.user.username, ); if (status) { Fluttertoast.showToast( @@ -194,7 +195,7 @@ class _CustomFollowersState extends State { ); setState(() { widget.user.blockedByMe = false; - widget.user.followedByMe = true; + widget.user.followedByMe = false; }); } else { Fluttertoast.showToast( @@ -350,9 +351,9 @@ class _CustomFollowersState extends State { String getText() { String status; - if (widget.user.blocksMe!) { + if (widget.user.blocksMe) { status = 'Blocked you'; - } else if (widget.user.blockedByMe!) { + } else if (widget.user.blockedByMe) { status = 'Blocked'; } else if (!widget.user.followedByMe) { if (kIsWeb) { diff --git a/lib/components/settings/update_username_components/update_username_button.dart b/lib/components/settings/update_username_components/update_username_button.dart index ecba242c..3d184788 100644 --- a/lib/components/settings/update_username_components/update_username_button.dart +++ b/lib/components/settings/update_username_components/update_username_button.dart @@ -28,7 +28,7 @@ class UpdateUsernameButton extends StatelessWidget { onPressed: () async { if (formKey.currentState!.validate()) { try { - dynamic response = await service.updateUsername(username); + dynamic response = await service.updateUsername(null,username); if (response is String) { showToastWidget( diff --git a/lib/components/sign_choose.dart b/lib/components/sign_choose.dart index 91851b32..0e6f7671 100644 --- a/lib/components/sign_choose.dart +++ b/lib/components/sign_choose.dart @@ -1,5 +1,4 @@ import 'package:dio/dio.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:oktoast/oktoast.dart'; @@ -7,7 +6,6 @@ import 'package:sign_button/sign_button.dart'; import 'package:tweaxy/components/sign_in_with.dart'; import 'package:tweaxy/components/start_screen_divider.dart'; import 'package:tweaxy/components/toasts/custom_toast.dart'; -import 'package:tweaxy/components/toasts/custom_web_toast.dart'; import 'package:tweaxy/constants.dart'; import 'package:tweaxy/services/sign_in_google.dart'; @@ -41,7 +39,7 @@ class _SignChooseState extends State { await GoogleAPI().login() as Map; if (user == null) { showToastWidget( - CustomToast( + const CustomToast( message: 'Faild to login with google', ), position: ToastPosition.bottom, diff --git a/lib/cubits/Tweets/tweet_cubit.dart b/lib/cubits/Tweets/tweet_cubit.dart index 5cb54b7b..328ff24c 100644 --- a/lib/cubits/Tweets/tweet_cubit.dart +++ b/lib/cubits/Tweets/tweet_cubit.dart @@ -1,6 +1,5 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:tweaxy/cubits/Tweets/tweet_states.dart'; -import 'package:tweaxy/models/tweet.dart'; class TweetsUpdateCubit extends Cubit { TweetsUpdateCubit() : super(TweetInitialState()); diff --git a/lib/cubits/Tweets/tweet_states.dart b/lib/cubits/Tweets/tweet_states.dart index 1e966361..96dc5017 100644 --- a/lib/cubits/Tweets/tweet_states.dart +++ b/lib/cubits/Tweets/tweet_states.dart @@ -1,4 +1,3 @@ -import 'package:tweaxy/models/tweet.dart'; class TweetUpdateState {} diff --git a/lib/cubits/edit_profile_cubit/edit_profile_cubit.dart b/lib/cubits/edit_profile_cubit/edit_profile_cubit.dart index fd97ad63..6adf218d 100644 --- a/lib/cubits/edit_profile_cubit/edit_profile_cubit.dart +++ b/lib/cubits/edit_profile_cubit/edit_profile_cubit.dart @@ -24,6 +24,7 @@ class EditProfileCubit extends Cubit { removedBanner: removedBanner, token: token); await GetUserById.instance.excute(user.id!); + emit(ProfilePageCompletedState()); } } diff --git a/lib/cubits/sidebar_cubit/sidebar_cubit.dart b/lib/cubits/sidebar_cubit/sidebar_cubit.dart index 304c6939..32cf78fd 100644 --- a/lib/cubits/sidebar_cubit/sidebar_cubit.dart +++ b/lib/cubits/sidebar_cubit/sidebar_cubit.dart @@ -36,6 +36,10 @@ class SidebarCubit extends Cubit { } void openFollowers({required String username, required String name}) { - emit(FollowingFollowerListState(username,name)); + emit(FollowingFollowerListState(username, name)); + } + + void showReplies(String tweetid, String userHandle, List replyto) { + emit(OpenRepliesState(tweetid, userHandle, replyto)); } } diff --git a/lib/cubits/sidebar_cubit/sidebar_states.dart b/lib/cubits/sidebar_cubit/sidebar_states.dart index bf8aeb8f..105e9a78 100644 --- a/lib/cubits/sidebar_cubit/sidebar_states.dart +++ b/lib/cubits/sidebar_cubit/sidebar_states.dart @@ -28,3 +28,10 @@ class FollowingFollowerListState extends SidebarState { FollowingFollowerListState(this.username, this.name); } + +class OpenRepliesState extends SidebarState { +final String tweetid; +final String userHandle; +final Listreplyto; + OpenRepliesState(this.tweetid, this.userHandle, this.replyto); +} diff --git a/lib/main.dart b/lib/main.dart index decbdb10..0e3db74a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -17,7 +17,6 @@ import 'package:tweaxy/views/settings/settings_view.dart'; import 'package:tweaxy/views/settings/settings_and_privacy_view.dart'; import 'package:tweaxy/views/settings/update_password_view.dart'; import 'package:tweaxy/views/followersAndFollowing/likers_in_tweet.dart'; -import 'package:tweaxy/views/followersAndFollowing/web_followers_followings.dart'; import 'package:tweaxy/cubits/Tweets/tweet_cubit.dart'; import 'package:tweaxy/views/search_users/search_users.dart'; import 'package:tweaxy/views/signup/mobile/create_account_data_review_view.dart'; @@ -106,7 +105,7 @@ class TweaXy extends StatelessWidget { kNotificationScreen: (context) => const NotificationScreen(), kCreateAcountReviewScreen: (context) => const CreateAccountDataReview(), - kProfileScreen: (context) => ProfileScreen( + kProfileScreen: (context) => const ProfileScreen( id: '', text: '', ), @@ -118,7 +117,7 @@ class TweaXy extends StatelessWidget { kLikersInTweets: (context) => LikersInTweet(id: 'sfr1ztrbdopvclujg0boys62a'), kAccountinfo: (context) => const AccountIfoView(), - kSettingsAndPrivacy: (context) => SettingsAndPrivacyView(), + kSettingsAndPrivacy: (context) => const SettingsAndPrivacyView(), kSettings: (context) => const SettingsView(), kPrivacySafetySettings: (context) => const SettingsPrivacySafetyScreen(), diff --git a/lib/models/tweet.dart b/lib/models/tweet.dart index e1b063e8..beb4c026 100644 --- a/lib/models/tweet.dart +++ b/lib/models/tweet.dart @@ -51,6 +51,7 @@ class Tweet { return id; } + @override String toString() { return 'Tweet {' 'userImage: $userImage, ' diff --git a/lib/models/user_notification.dart b/lib/models/user_notification.dart index adf7f886..a41cf998 100644 --- a/lib/models/user_notification.dart +++ b/lib/models/user_notification.dart @@ -1,5 +1,4 @@ import 'package:tweaxy/models/interaction_model.dart'; -import 'package:tweaxy/models/user.dart'; class UserNotification { String? userId; diff --git a/lib/services/chat_room_service.dart b/lib/services/chat_room_service.dart index 15ae24ad..14e0e705 100644 --- a/lib/services/chat_room_service.dart +++ b/lib/services/chat_room_service.dart @@ -1,5 +1,4 @@ import 'dart:developer'; -import 'dart:io'; import 'package:chatview/chatview.dart'; // import 'package:dash_chat_2/dash_chat_2.dart'; @@ -12,15 +11,20 @@ class ChatRoomService { final Dio dio; late String userID; ChatRoomService(this.dio); - Future> getMessages(String id, int pageOffset) async { + Future> getMessages( + String? tokenSent, String id, int pageOffset) async { Response response; String? token; - try { - List s = await loadPrefs(); - token = s[1]; - userID = s[0]; - } catch (e) { - log(e.toString()); + if (tokenSent != null) { + token = tokenSent; + } else { + try { + List s = await loadPrefs(); + token = s[1]; + userID = s[0]; + } catch (e) { + log(e.toString()); + } } try { response = await Api.getwithToken( @@ -79,15 +83,19 @@ class ChatRoomService { // return messages; // } - Future firstConversation(String username) async { + Future firstConversation(String? tokenSent, String username) async { String returndata = ""; Response response; String? token; - try { - List s = await loadPrefs(); - token = s[1]; - } catch (e) { - log(e.toString()); + if (tokenSent != null) { + token = tokenSent; + } else { + try { + List s = await loadPrefs(); + token = s[1]; + } catch (e) { + log(e.toString()); + } } try { response = await Api.post( diff --git a/lib/services/get_likers_in_profile.dart b/lib/services/get_likers_in_profile.dart index 84b92f34..2a7cc2f8 100644 --- a/lib/services/get_likers_in_profile.dart +++ b/lib/services/get_likers_in_profile.dart @@ -29,7 +29,7 @@ class GetLikersInProfile { // Response response = res; // print('rrrrr' + res.toString()); - List> m =await mapToList(response); + List> m =mapToList(response); List t = initializeTweets(m); // print('hh' + m.whereType().toString()); return t; diff --git a/lib/services/get_mentioned_tweets.dart b/lib/services/get_mentioned_tweets.dart index f9cc6993..e500fb73 100644 --- a/lib/services/get_mentioned_tweets.dart +++ b/lib/services/get_mentioned_tweets.dart @@ -12,7 +12,7 @@ class GetMentionedTweets { url: '$baseURL$_endpoint$id?limit=$pageSize&offset=$offset', token: token, ); - List> m = await mapToList(response); + List> m = mapToList(response); List tweets = initializeTweets(m); return tweets; } diff --git a/lib/services/get_search_tweets.dart b/lib/services/get_search_tweets.dart index 8211e392..c414c4b2 100644 --- a/lib/services/get_search_tweets.dart +++ b/lib/services/get_search_tweets.dart @@ -43,10 +43,10 @@ class SearchTweetTweets { if (response is String) { return []; } - List> m = await mapToList(response); - print('ressss' + m.toString()); + List> m = mapToList(response); + print('ressss$m'); - print('mm' + m.toString()); + print('mm$m'); List t = initializeTweets(m); // print('hh' + m.whereType().toString()); return t; diff --git a/lib/services/get_user_by_id.dart b/lib/services/get_user_by_id.dart index 1cfc1eb8..a5f944d4 100644 --- a/lib/services/get_user_by_id.dart +++ b/lib/services/get_user_by_id.dart @@ -14,7 +14,7 @@ class GetUserById { } Future getUserById(String id) async { - print('uuu'+id.toString()); + print('uuu$id'); var response = await Api.getwithToken( url: baseURL + _endpoint + id, token: TempUser.token); var data = response.data; diff --git a/lib/services/like_tweet.dart b/lib/services/like_tweet.dart index 32571700..15b6b264 100644 --- a/lib/services/like_tweet.dart +++ b/lib/services/like_tweet.dart @@ -2,7 +2,7 @@ import 'package:dio/dio.dart'; import 'package:tweaxy/constants.dart'; class LikeTweet { - static final String _endpoint = 'interactions/'; + static const String _endpoint = 'interactions/'; LikeTweet._(); static Future likeTweet(String id, String token) async { var dio = Dio(); diff --git a/lib/services/login_api.dart b/lib/services/login_api.dart index 817a5eae..1614bbc8 100644 --- a/lib/services/login_api.dart +++ b/lib/services/login_api.dart @@ -15,8 +15,8 @@ class LoginApi { "Content-Type": "application/json", })); SharedPreferences user = await SharedPreferences.getInstance(); - print('kk'+response.data.toString()); - print('kkkk'+response.data['data']['token'].toString()); + print('kk${response.data}'); + print('kkkk${response.data['data']['token']}'); user.setString('username', response.data['data']['user']['username']); user.setString("token", response.data['data']['token']); diff --git a/lib/services/notification_settings_service.dart b/lib/services/notification_settings_service.dart index ba813073..ceefa29f 100644 --- a/lib/services/notification_settings_service.dart +++ b/lib/services/notification_settings_service.dart @@ -10,8 +10,8 @@ class NotificationSettingsService { NotificationSettingsService(this.dio); Future notificatioCheckState(String deviceToken) async { - Response response; - dynamic returnvalue; + dynamic response; + // dynamic returnvalue; String? token; try { SharedPreferences prefs = await SharedPreferences.getInstance(); @@ -26,16 +26,16 @@ class NotificationSettingsService { token: token, body: {"token": deviceToken, "type": "android"}, ); - if (response.statusCode == 200) { - if (response.data["data"]["status"] == "enabled") { - returnvalue = "true"; - } else if (response.data["data"]["status"] == "disabled") { - returnvalue = "false"; - } - } else { - returnvalue = response; - } - return returnvalue; + // if (response.statusCode == 200) { + // if (response.data["data"]["status"] == "enabled") { + // returnvalue = "true"; + // } else if (response.data["data"]["status"] == "disabled") { + // returnvalue = "false"; + // } + // } else { + // returnvalue = response; + // } + return response; } catch (e) { log(e.toString()); throw Exception('notification State error'); diff --git a/lib/services/sign_in.dart b/lib/services/sign_in.dart index 57ce367c..b906b0c6 100644 --- a/lib/services/sign_in.dart +++ b/lib/services/sign_in.dart @@ -44,7 +44,7 @@ class SignInServices { if (res is String) { return res; } else { - print('token' + res.data['data']['token'].toString()); + print('token${res.data['data']['token']}'); SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setString("token", res.data['data']['token'].toString()); prefs.setString("id", res.data['data']['userId'].toString()); diff --git a/lib/services/sign_in_google.dart b/lib/services/sign_in_google.dart index 3df2bac9..cf1d8193 100644 --- a/lib/services/sign_in_google.dart +++ b/lib/services/sign_in_google.dart @@ -45,13 +45,13 @@ class GoogleAPI { await GoogleSignIn().signOut(); String token = await signInWithGoogle(); - if (token.length > 0) { + if (token.isNotEmpty) { Response response = await dio.post( '${baseURL}auth/google/android/', data: {'token': token}); SharedPreferences user = await SharedPreferences.getInstance(); - print('kk' + response.data.toString()); - print('kkkk' + response.data['data']['token'].toString()); + print('kk${response.data}'); + print('kkkk${response.data['data']['token']}'); user.setString('username', response.data['data']['user']['username']); user.setString("token", response.data['data']['token']); @@ -62,7 +62,8 @@ class GoogleAPI { print(response.data['data']['user']['username']); await GoogleSignIn().signOut(); return response.data; - } else + } else { return null; + } } } diff --git a/lib/services/temp_user.dart b/lib/services/temp_user.dart index bd9ad03b..ea74d43f 100644 --- a/lib/services/temp_user.dart +++ b/lib/services/temp_user.dart @@ -40,29 +40,26 @@ class TempUser { TempUser.id = id; } - static void userSetData(context) async { + static Future userSetData(context, {bool refresh = true}) async { // print(email); SharedPreferences prefs = await SharedPreferences.getInstance(); String? userid = prefs.getString('id'); String? token = prefs.getString('token'); setToken(token: token!); - dynamic result = await Api.getwithToken( - token: token, - url: '${baseURL}users/$userid'); + dynamic result = + await Api.getwithToken(token: token, url: '${baseURL}users/$userid'); if (result is String) { } else if (result is Response) { - Response res = result; setId(id: userid!); setEmail(email: res.data['data']['user']['email']); setName(name: res.data['data']['user']['name']); setUserName(username: res.data['data']['user']['username']); setImage( - image: res.data['data']['user']['avatar'] ?? 'b631858bdaafa77258b9ed2f7c689bdb.png'); - - - BlocProvider.of(context).refresh(); - + image: res.data['data']['user']['avatar']); + if (refresh) { + BlocProvider.of(context).refresh(); + } } } } diff --git a/lib/services/tweets_services.dart b/lib/services/tweets_services.dart index 6037715f..cd1e2986 100644 --- a/lib/services/tweets_services.dart +++ b/lib/services/tweets_services.dart @@ -20,10 +20,10 @@ class TweetsServices { return []; } - List> m = await mapToList(res); + List> m = mapToList(res); List t = initializeTweets(m); - print('tt' + t.toString()); + print('tt$t'); // print('hh' + m.whereType().toString()); return t; } @@ -35,10 +35,11 @@ class TweetsServices { print(tweetid); dynamic res = await Api.delete(url: '${baseURL}interactions/$tweetid', token: s); - if (res is String) + if (res is String) { return res; - else + } else { return "success"; + } } static Future> getProfilePosts( @@ -55,7 +56,7 @@ class TweetsServices { // Response response = res; // print('rrrrr' + res.toString()); - List> m = await mapToList(res); + List> m = mapToList(res); List t = initializeTweets(m); // print('hh' + m.whereType().toString()); return t; @@ -64,7 +65,7 @@ class TweetsServices { static Future> isFollowed(String userid) async { dynamic result = await Api.getwithToken( token: TempUser.token, url: '${baseURL}users/$userid'); - print('resulttt' + result.toString()); + print('resulttt$result'); if (result is String) { return []; } else if (result is Response) { @@ -93,10 +94,10 @@ class TweetsServices { // Response response = res; // print('rrrrr' + res.toString()); - List> m = await mapToList(res); - print('ressss' + m.toString()); + List> m = mapToList(res); + print('ressss$m'); - print('mm' + m.toString()); + print('mm$m'); List t = initializeTweets(m); // print('hh' + m.whereType().toString()); return t; @@ -116,11 +117,11 @@ class TweetsServices { } // Response response = res; if (res.data['data'] == []) return []; - print('rrrrr' + res.data['data'].toString()); + print('rrrrr${res.data['data']}'); List> m = mapToList(res, isforreply: true); - print('ressss' + m.toString()); + print('ressss$m'); - print('mm' + m.toString()); + print('mm$m'); List t = initializeTweets(m); // print('hh' + m.whereType().toString()); return t; @@ -147,11 +148,7 @@ class TweetsServices { ['commentsCount'], id: res.data['data']['parent']['mainInteraction']['id'], userId: res.data['data']['parent']['mainInteraction']['user']['id'], - userImage: res.data['data']['parent']['mainInteraction']['user'] - ['avatar'] != - null - ? res.data['data']['parent']['mainInteraction']['user']['avatar'] - : 'b631858bdaafa77258b9ed2f7c689bdb.png', + userImage: res.data['data']['parent']['mainInteraction']['user']['avatar'] ?? 'b631858bdaafa77258b9ed2f7c689bdb.png', image: res.data['data']['parent']['mainInteraction']['media'] != null ? getImageList( res.data['data']['parent']['mainInteraction']['media'].toList()) @@ -209,10 +206,11 @@ class TweetsServices { String? s = prefs.getString('token'); dynamic res = await Api.delete( url: '${baseURL}interactions/retweet/$tweetid', token: s); - if (res is String) + if (res is String) { return false; - else + } else { return true; + } } } diff --git a/lib/services/update_password_service.dart b/lib/services/update_password_service.dart index 9d9c0726..8c778f1c 100644 --- a/lib/services/update_password_service.dart +++ b/lib/services/update_password_service.dart @@ -8,17 +8,21 @@ class UpdatePasswordService { final Dio dio; UpdatePasswordService(this.dio); Future updatePassword( + String? tokenSent, {required String oldPassword, required String newPassword, required String confirmPassword}) async { dynamic response; String? token; - try { + if (tokenSent != null) { + token = tokenSent; + } else + {try { List s = await loadPrefs(); token = s[1]; } catch (e) { log(e.toString()); - } + }} final data = { "oldPassword": oldPassword, "newPassword": newPassword, diff --git a/lib/services/update_username_service.dart b/lib/services/update_username_service.dart index 31554357..f1428f21 100644 --- a/lib/services/update_username_service.dart +++ b/lib/services/update_username_service.dart @@ -9,14 +9,18 @@ class UpdateUsernameService { final Dio dio; UpdateUsernameService(this.dio); - Future updateUsername(String newUsername) async { + Future updateUsername(String? tokenSent, String newUsername) async { dynamic response; String? token; - try { - SharedPreferences prefs = await SharedPreferences.getInstance(); - token = prefs.getString('token'); - } catch (e) { - log(e.toString()); + if (tokenSent != null) { + token = tokenSent; + } else { + try { + SharedPreferences prefs = await SharedPreferences.getInstance(); + token = prefs.getString('token'); + } catch (e) { + log(e.toString()); + } } try { response = await Api.patch( @@ -30,7 +34,7 @@ class UpdateUsernameService { } catch (e) { log(e.toString()); //debug mode only - throw Exception('Capthca authentication error'); + throw Exception('update username error'); } } } diff --git a/lib/shared/keys/tweet_keys.dart b/lib/shared/keys/tweet_keys.dart index b60cc30d..8dac8fef 100644 --- a/lib/shared/keys/tweet_keys.dart +++ b/lib/shared/keys/tweet_keys.dart @@ -9,9 +9,13 @@ class TweetKeys { 'repost_button_replies_screen'; static const String likeInteractionRepliesScreen = 'like_button_replies_screen'; - static const String deleteTweetRepliesScreen = - 'like_button_replies_screen'; - static const String followButtonRepliesScreen = + static const String deleteTweetRepliesScreen = 'like_button_replies_screen'; + static const String followButtonRepliesScreen = 'follow_button_replies_screen'; + //Tweet Settings + static const String openTweetSettings = 'open_tweet_settings_button'; + static const String followUserFromTweet = 'follow_user_from_tweet_button'; + static const String blockUserFromTweet = 'block_user_from_tweet_button'; + static const String muteUserFromTweet = 'mute_user_from_tweet_button'; } diff --git a/lib/utilities/tweets_utilities.dart b/lib/utilities/tweets_utilities.dart index 7dd6c368..974a3048 100644 --- a/lib/utilities/tweets_utilities.dart +++ b/lib/utilities/tweets_utilities.dart @@ -89,7 +89,7 @@ String dateFormatter(String date) { else if (now.second - dt1.second > 0) time = '${now.second - dt1.second}s'; else - time = months[dt1.month - 1] + ' ' + dt1.day.toString(); + time = '${months[dt1.month - 1]} ${dt1.day}'; // print('time=' + time.toString()); return time; } @@ -97,47 +97,41 @@ String dateFormatter(String date) { List calculateTime(String fulldate) { DateTime dt1 = DateTime.parse(fulldate).toLocal(); print(fulldate.toString()); - print('ddd' + dt1.hour.toString()); + print('ddd${dt1.hour}'); String time; String date; String min = ''; - if (dt1.minute < 10) - min += ':' + '0' + '${dt1.minute}'; - else - min += ':' + '${dt1.minute}'; - if (dt1.hour == 0) - time = '12' + min + ' ' + 'AM'; - else if (dt1.hour <= 12) - time = '${dt1.hour}' + min + ' ' + 'AM'; - else - time = '${dt1.hour - 12}' + min + ' ' + 'PM'; - if (dt1.day < 10) - date = '0' + - '${dt1.day}' + - ' ' + - '${months[dt1.month - 1]}' + - ' ' + - '${dt1.year - 2000}'; + if (dt1.minute < 10) { + min += ':0${dt1.minute}'; + } else { + min += ':' '${dt1.minute}'; + } + if (dt1.hour == 0) { + time = '12$min AM'; + } else if (dt1.hour <= 12) + time = '${dt1.hour}$min AM'; else - date = '${dt1.day}' + - ' ' + - '${months[dt1.month - 1]}' + - ' ' + - '${dt1.year - 2000}'; + time = '${dt1.hour - 12}$min PM'; + if (dt1.day < 10) { + date = '0${dt1.day} ${months[dt1.month - 1]} ${dt1.year - 2000}'; + } else { + date = '${dt1.day} ${months[dt1.month - 1]} ${dt1.year - 2000}'; + } return [time, date]; } List> mapToList(Response res, {bool isforreply = false, bool isformaintweetreply = false}) { List t = []; - if (isformaintweetreply) + if (isformaintweetreply) { t = res.data['data']['parent'] as List; - else + } else { t = isforreply ? res.data['data']['interactions'] : res.data['data']['items']; - return (t as List).map((item) { + } + return (t).map((item) { String x = 'mainInteraction'; String reposteruserid = ''; String reposteruserName = ''; @@ -153,9 +147,7 @@ List> mapToList(Response res, 'commentsCount': item[x]['commentsCount'], 'id': item['mainInteraction']['id'], 'userid': item[x]['user']['id'], - 'userImage': item[x]['user']['avatar'] != null - ? item[x]['user']['avatar'] - : 'b631858bdaafa77258b9ed2f7c689bdb.png', + 'userImage': item[x]['user']['avatar'] ?? 'b631858bdaafa77258b9ed2f7c689bdb.png', 'image': item[x]['media'] != null ? item[x]['media'].toList() : null, 'userName': item[x]['user']['name'], 'userHandle': item[x]['user']['username'], @@ -228,7 +220,7 @@ void updateStatesforTweet(state, context, PagingController pagingController, state is TweetUserUnfollowed) && isforHome) { pagingController.itemList!.removeWhere((element) { - print(element.userId.toString() + ' ' + state.userid.toString()); + print('${element.userId} ${state.userid}'); return element.userId == state.userid; }); BlocProvider.of(context).initializeTweet(); diff --git a/lib/views/chat/chat_room.dart b/lib/views/chat/chat_room.dart index 795f3641..836ebf36 100644 --- a/lib/views/chat/chat_room.dart +++ b/lib/views/chat/chat_room.dart @@ -4,6 +4,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:chatview/chatview.dart'; +import 'package:flutter/rendering.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:socket_io_client/socket_io_client.dart' as ioo; import 'package:tweaxy/constants.dart'; @@ -16,7 +17,7 @@ import 'package:tweaxy/views/profile/profile_screen.dart'; class ChatRoom extends StatefulWidget { ChatRoom( - {required this.id, + {super.key, required this.id, required this.avatar, required this.username, required this.isFirstMsg, @@ -60,14 +61,14 @@ class _ChatRoomState extends State { usertoken = s[1]; userID = s[0]; consversationID = - await ChatRoomService(Dio()).firstConversation(widget.username); + await ChatRoomService(Dio()).firstConversation(null, widget.username); if (widget.conversationID != "") { - oldMessages = - await ChatRoomService(Dio()).getMessages(widget.conversationID, 0); + oldMessages = await ChatRoomService(Dio()) + .getMessages(null, widget.conversationID, 0); consversationID = widget.conversationID; } else { oldMessages = - await ChatRoomService(Dio()).getMessages(consversationID, 0); + await ChatRoomService(Dio()).getMessages(null, consversationID, 0); } if (oldMessages.isEmpty) { chatViewState.value = ChatViewState.noData; @@ -128,13 +129,15 @@ class _ChatRoomState extends State { void initState() { ScrollController scrollController = ScrollController(); scrollController.addListener(() { - if (scrollController.position.pixels >= - scrollController.position.maxScrollExtent - 10 && + if (scrollController.position.userScrollDirection == + ScrollDirection.reverse && tany) { setState(() { isLastPage = true; }); - } else { + } + if (scrollController.position.userScrollDirection == + ScrollDirection.forward) { setState(() { isLastPage = false; // Reset isLastPage to false when scrolling down }); @@ -231,53 +234,39 @@ class _ChatRoomState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ if (isLastPage && !widget.isFirstMsg) - GestureDetector( - behavior: HitTestBehavior.translucent, - onTap: () { - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (context) => ProfileScreen( - // id: widget.id, - // text: "yara", - // ), - // ), - // ); - }, - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.only(bottom: 8.0), - child: CircleAvatar( - radius: 25, - backgroundColor: Colors.blueGrey[300], - backgroundImage: CachedNetworkImageProvider( - basePhotosURL + widget.avatar!), - ), - ), - Text( - widget.name, - style: const TextStyle(fontWeight: FontWeight.bold), + Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: CircleAvatar( + radius: 25, + backgroundColor: Colors.blueGrey[300], + backgroundImage: CachedNetworkImageProvider( + basePhotosURL + widget.avatar!), ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 5.0), - child: Text( - "@${widget.username}", - style: TextStyle(color: Colors.grey.shade600), - ), + ), + Text( + widget.name, + style: const TextStyle(fontWeight: FontWeight.bold), + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 5.0), + child: Text( + "@${widget.username}", + style: TextStyle(color: Colors.grey.shade600), ), - Padding( - padding: const EdgeInsets.only(bottom: 5.0), - child: Text( - "Followers: ${widget.userFollowersNum} . Followings: ${widget.userFollowingsNum} ", - style: TextStyle(color: Colors.grey.shade600), - ), + ), + Padding( + padding: const EdgeInsets.only(bottom: 5.0), + child: Text( + "Followers: ${widget.userFollowersNum} . Followings: ${widget.userFollowingsNum} ", + style: TextStyle(color: Colors.grey.shade600), ), - const Divider(), - ], - ), + ), + const Divider(), + ], ), Expanded( child: Obx( @@ -289,7 +278,7 @@ class _ChatRoomState extends State { loadMoreData: () async { if (!isLastPage) { var newMessages = await ChatRoomService(Dio()) - .getMessages(consversationID, pageOffset); + .getMessages(null, consversationID, pageOffset); newMessages = newMessages.reversed.toList(); _chatController.loadMoreData(newMessages); pageOffset += newMessages.length; @@ -339,6 +328,8 @@ class _ChatRoomState extends State { textStyle: const TextStyle(color: Colors.black), ), allowRecordingVoice: false, + enableCameraImagePicker: false, + enableGalleryImagePicker: false, ), chatBubbleConfig: ChatBubbleConfiguration( outgoingChatBubbleConfig: const ChatBubble( diff --git a/lib/views/chat/direct_message.dart b/lib/views/chat/direct_message.dart index f86b0a3a..fdfb017b 100644 --- a/lib/views/chat/direct_message.dart +++ b/lib/views/chat/direct_message.dart @@ -3,9 +3,6 @@ import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:tweaxy/components/chat/custom_chat_user.dart'; -import 'package:tweaxy/components/custom_followers.dart'; -import 'package:tweaxy/models/followers_model.dart'; -import 'package:tweaxy/models/user.dart'; import 'package:tweaxy/models/user_chat.dart'; import 'package:tweaxy/services/search_for_users.dart'; import 'package:tweaxy/services/temp_user.dart'; @@ -62,12 +59,10 @@ class _DirectMesssageState extends State { _pagingController.appendPage(newItems, nextPageKey); } } catch (error) { - _pagingController.error = Container( - child: const Center( - child: Text( - 'No results found', - style: TextStyle(color: Colors.black), - ), + _pagingController.error = const Center( + child: Text( + 'No results found', + style: TextStyle(color: Colors.black), ), ); } @@ -188,10 +183,11 @@ class _DirectMesssageState extends State { child: SpinKitRing(color: Colors.blueAccent), ), itemBuilder: (context, item, index) { - if (item.id == TempUser.id) + if (item.id == TempUser.id) { return const SizedBox(); - else + } else { return CustomUserChat(user: item); + } }, ), ) diff --git a/lib/views/chat/get_conversations_view.dart b/lib/views/chat/get_conversations_view.dart index 1741580d..627fd56b 100644 --- a/lib/views/chat/get_conversations_view.dart +++ b/lib/views/chat/get_conversations_view.dart @@ -54,7 +54,12 @@ class _GetConversationsViewState extends State { _pagingController.appendPage(newItems, nextPageKey); } } catch (error) { - _pagingController.error = error; + _pagingController.error = const Center( + child: Text( + 'No results found', + style: TextStyle(color: Colors.black), + ), + ); } setState(() {}); } @@ -106,7 +111,6 @@ class _GetConversationsViewState extends State { _pagingController.addPageRequestListener((pageKey) { _fetchPage(pageKey); }); - return const Center( child: CircularProgressIndicator( color: Colors.blue, diff --git a/lib/views/chat/web/chat_room_web.dart b/lib/views/chat/web/chat_room_web.dart index 849d2c25..a885b0de 100644 --- a/lib/views/chat/web/chat_room_web.dart +++ b/lib/views/chat/web/chat_room_web.dart @@ -4,6 +4,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:chatview/chatview.dart'; +import 'package:flutter/rendering.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:socket_io_client/socket_io_client.dart' as ioo; import 'package:tweaxy/constants.dart'; @@ -62,14 +63,14 @@ class _ChatRoomWebState extends State { usertoken = s[1]; userID = s[0]; consversationID = - await ChatRoomService(Dio()).firstConversation(widget.username); + await ChatRoomService(Dio()).firstConversation(null, widget.username); if (widget.conversationID != "") { - oldMessages = - await ChatRoomService(Dio()).getMessages(widget.conversationID, 0); + oldMessages = await ChatRoomService(Dio()) + .getMessages(null, widget.conversationID, 0); consversationID = widget.conversationID; } else { oldMessages = - await ChatRoomService(Dio()).getMessages(consversationID, 0); + await ChatRoomService(Dio()).getMessages(null, consversationID, 0); } if (oldMessages.isEmpty) { chatViewState.value = ChatViewState.noData; @@ -130,13 +131,15 @@ class _ChatRoomWebState extends State { void initState() { ScrollController scrollController = ScrollController(); scrollController.addListener(() { - if (scrollController.position.pixels == - scrollController.position.maxScrollExtent && + if (scrollController.position.userScrollDirection == + ScrollDirection.reverse && tany) { setState(() { isLastPage = true; }); - } else { + } + if (scrollController.position.userScrollDirection == + ScrollDirection.forward) { setState(() { isLastPage = false; // Reset isLastPage to false when scrolling down }); @@ -271,7 +274,7 @@ class _ChatRoomWebState extends State { loadMoreData: () async { if (!isLastPage) { var newMessages = await ChatRoomService(Dio()) - .getMessages(consversationID, pageOffset); + .getMessages(null, consversationID, pageOffset); newMessages = newMessages.reversed.toList(); _chatController.loadMoreData(newMessages); pageOffset += newMessages.length; diff --git a/lib/views/chat/web/get_conversations_web_view.dart b/lib/views/chat/web/get_conversations_web_view.dart index d3b0cc74..9f8aaae8 100644 --- a/lib/views/chat/web/get_conversations_web_view.dart +++ b/lib/views/chat/web/get_conversations_web_view.dart @@ -4,7 +4,6 @@ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; -import 'package:tweaxy/components/chat/conversation.dart'; import 'package:tweaxy/components/chat/conversation_web.dart'; import 'package:tweaxy/components/custom_head_text.dart'; import 'package:tweaxy/components/custom_paragraph_text.dart'; @@ -13,7 +12,6 @@ import 'package:tweaxy/cubits/chat_web_cubit/chat_web_states.dart'; import 'package:tweaxy/models/app_icons.dart'; import 'package:tweaxy/models/conversation_model.dart'; import 'package:tweaxy/services/get_conversation_service.dart'; -import 'package:tweaxy/views/chat/chat_room.dart'; import 'package:tweaxy/views/chat/web/chat_room_web.dart'; import 'package:tweaxy/views/chat/web/diect_message_web.dart'; import 'package:tweaxy/views/chat/web/no_convesations_web_view.dart'; @@ -59,7 +57,12 @@ class _GetConversationsWebViewState extends State { _pagingController.appendPage(newItems, nextPageKey); } } catch (error) { - _pagingController.error = error; + _pagingController.error = const Center( + child: Text( + 'No Conversations found', + style: TextStyle(color: Colors.black), + ), + ); } setState(() {}); } diff --git a/lib/views/followersAndFollowing/followers.dart b/lib/views/followersAndFollowing/followers.dart index a22a1141..4344008b 100644 --- a/lib/views/followersAndFollowing/followers.dart +++ b/lib/views/followersAndFollowing/followers.dart @@ -1,21 +1,17 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:tweaxy/components/HomePage/floating_action_button.dart'; import 'package:tweaxy/components/custom_followers.dart'; -import 'package:tweaxy/components/toasts/custom_toast.dart'; -import 'package:tweaxy/components/toasts/custom_web_toast.dart'; import 'package:tweaxy/cubits/updata/updata_cubit.dart'; import 'package:tweaxy/cubits/updata/updata_states.dart'; import 'package:tweaxy/models/followers_model.dart'; import 'package:tweaxy/services/FollowersAndFollwing.dart'; -import 'package:tweaxy/views/followersAndFollowing/custom_future.dart'; import 'package:tweaxy/views/loading_screen.dart'; class FollowersPage extends StatefulWidget { - FollowersPage({required this.username}); + FollowersPage({super.key, required this.username}); String username; @override State createState() => _FollowersPageState(); @@ -74,7 +70,7 @@ class _FollowersPageState extends State { _pagingController.addPageRequestListener((pageKey) { _fetchPage(pageKey); }); - return LoadingScreen(asyncCall: true); + return const LoadingScreen(asyncCall: true); } else { return Scaffold( appBar: AppBar( diff --git a/lib/views/followersAndFollowing/following.dart b/lib/views/followersAndFollowing/following.dart index 5d1fd0c6..30cfebe2 100644 --- a/lib/views/followersAndFollowing/following.dart +++ b/lib/views/followersAndFollowing/following.dart @@ -1,21 +1,16 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:tweaxy/components/custom_followers.dart'; -import 'package:tweaxy/components/showallFollowers.dart'; -import 'package:tweaxy/components/toasts/custom_toast.dart'; -import 'package:tweaxy/components/toasts/custom_web_toast.dart'; import 'package:tweaxy/cubits/updata/updata_cubit.dart'; import 'package:tweaxy/cubits/updata/updata_states.dart'; import 'package:tweaxy/models/followers_model.dart'; import 'package:tweaxy/services/FollowersAndFollwing.dart'; -import 'package:tweaxy/views/followersAndFollowing/custom_future.dart'; import 'package:tweaxy/views/loading_screen.dart'; class FollowingPage extends StatefulWidget { - FollowingPage({required this.username}); + FollowingPage({super.key, required this.username}); String username; @override State createState() => _FollowingPageState(); diff --git a/lib/views/followersAndFollowing/likers_in_tweet.dart b/lib/views/followersAndFollowing/likers_in_tweet.dart index 40860453..eb022209 100644 --- a/lib/views/followersAndFollowing/likers_in_tweet.dart +++ b/lib/views/followersAndFollowing/likers_in_tweet.dart @@ -1,18 +1,13 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:tweaxy/components/HomePage/floating_action_button.dart'; import 'package:tweaxy/components/custom_followers.dart'; -import 'package:tweaxy/components/showallFollowers.dart'; -import 'package:tweaxy/components/toasts/custom_toast.dart'; -import 'package:tweaxy/components/toasts/custom_web_toast.dart'; import 'package:tweaxy/cubits/updata/updata_cubit.dart'; import 'package:tweaxy/cubits/updata/updata_states.dart'; import 'package:tweaxy/models/followers_model.dart'; import 'package:tweaxy/services/get_likers.dart'; -import 'package:tweaxy/views/followersAndFollowing/custom_future.dart'; import 'package:tweaxy/views/loading_screen.dart'; class LikersInTweet extends StatefulWidget { @@ -75,7 +70,7 @@ class _LikersInTweetState extends State { _pagingController.addPageRequestListener((pageKey) { _fetchPage(pageKey); }); - return LoadingScreen(asyncCall: true); + return const LoadingScreen(asyncCall: true); } else { // _pagingController.refresh(); return Scaffold( diff --git a/lib/views/followersAndFollowing/retweeters_in_tweet.dart b/lib/views/followersAndFollowing/retweeters_in_tweet.dart index 351d84a7..50d21895 100644 --- a/lib/views/followersAndFollowing/retweeters_in_tweet.dart +++ b/lib/views/followersAndFollowing/retweeters_in_tweet.dart @@ -1,19 +1,13 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:tweaxy/components/HomePage/floating_action_button.dart'; import 'package:tweaxy/components/custom_followers.dart'; -import 'package:tweaxy/components/showallFollowers.dart'; -import 'package:tweaxy/components/toasts/custom_toast.dart'; -import 'package:tweaxy/components/toasts/custom_web_toast.dart'; import 'package:tweaxy/cubits/updata/updata_cubit.dart'; import 'package:tweaxy/cubits/updata/updata_states.dart'; import 'package:tweaxy/models/followers_model.dart'; -import 'package:tweaxy/services/get_likers.dart'; import 'package:tweaxy/services/get_reposts.dart'; -import 'package:tweaxy/views/followersAndFollowing/custom_future.dart'; import 'package:tweaxy/views/loading_screen.dart'; class RepostsinTweet extends StatefulWidget { @@ -76,7 +70,7 @@ class _RepostsinTweetState extends State { _pagingController.addPageRequestListener((pageKey) { _fetchPage(pageKey); }); - return LoadingScreen(asyncCall: true); + return const LoadingScreen(asyncCall: true); } else { // _pagingController.refresh(); return Scaffold( diff --git a/lib/views/followersAndFollowing/web_followers_followings.dart b/lib/views/followersAndFollowing/web_followers_followings.dart index df252de9..ff516533 100644 --- a/lib/views/followersAndFollowing/web_followers_followings.dart +++ b/lib/views/followersAndFollowing/web_followers_followings.dart @@ -1,4 +1,3 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; diff --git a/lib/views/login/forget_password_page3.dart b/lib/views/login/forget_password_page3.dart index 11d1ccfc..293c7521 100644 --- a/lib/views/login/forget_password_page3.dart +++ b/lib/views/login/forget_password_page3.dart @@ -9,7 +9,6 @@ import 'package:tweaxy/components/custom_button.dart'; import 'package:tweaxy/components/transition/custom_page_route.dart'; import 'package:tweaxy/components/custom_text_form_field.dart'; import 'package:tweaxy/services/sign_in.dart'; -import 'package:tweaxy/utilities/custom_text_form_validations.dart'; import 'package:tweaxy/utilities/theme_validations.dart'; import 'package:tweaxy/views/login/forget_password_page1.dart'; diff --git a/lib/views/login/reset_password/reset_password_mobile.dart b/lib/views/login/reset_password/reset_password_mobile.dart index cee6fee1..3dd90191 100644 --- a/lib/views/login/reset_password/reset_password_mobile.dart +++ b/lib/views/login/reset_password/reset_password_mobile.dart @@ -1,8 +1,5 @@ import 'package:flutter/material.dart'; import 'package:oktoast/oktoast.dart'; -import 'package:shared_preferences/shared_preferences.dart'; -import 'package:tweaxy/components/custom_head_text.dart'; -import 'package:tweaxy/components/custom_paragraph_text.dart'; import 'package:tweaxy/shared/keys/sign_in_keys.dart'; import 'package:tweaxy/views/login/reset_password/reset_password_mobile2.dart'; import 'package:tweaxy/components/custom_appbar.dart'; diff --git a/lib/views/notifications/notification_screen.dart b/lib/views/notifications/notification_screen.dart index 107e1d4e..834acf38 100644 --- a/lib/views/notifications/notification_screen.dart +++ b/lib/views/notifications/notification_screen.dart @@ -7,19 +7,16 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:tweaxy/components/HomePage/Tweet/Replies/replies_screen.dart'; import 'package:tweaxy/components/HomePage/Tweet/tweet.dart'; -import 'package:tweaxy/components/HomePage/floating_action_button.dart'; import 'package:tweaxy/components/transition/custom_page_route.dart'; import 'package:tweaxy/constants.dart'; import 'package:tweaxy/cubits/sidebar_cubit/sidebar_cubit.dart'; import 'package:tweaxy/cubits/sidebar_cubit/sidebar_states.dart'; import 'package:tweaxy/models/tweet.dart'; -import 'package:tweaxy/models/user.dart'; import 'package:tweaxy/models/user_notification.dart'; import 'package:tweaxy/services/follow_user.dart'; import 'package:tweaxy/services/get_all_notifications.dart'; import 'package:tweaxy/services/get_mentioned_tweets.dart'; import 'package:tweaxy/services/temp_user.dart'; -import 'package:tweaxy/utilities/tweets_utilities.dart'; import 'package:tweaxy/views/profile/profile_screen.dart'; class NotificationScreen extends StatefulWidget { @@ -215,7 +212,7 @@ class _NotificationScreenState extends State { return _mentionsPagingController.refresh(); }, child: PagedListView.separated( - separatorBuilder: (context, index) => Divider( + separatorBuilder: (context, index) => const Divider( color: Colors.grey, ), pagingController: _mentionsPagingController, @@ -232,7 +229,7 @@ class _NotificationScreenState extends State { ), ), Padding( - padding: const EdgeInsets.all(20.0), + padding: EdgeInsets.all(20.0), child: Text( 'Any mention notification on post will appear here', style: TextStyle( @@ -306,7 +303,7 @@ class _AllNotificationsListTileState extends State { CustomPageRoute( child: RepliesScreen( tweetid: widget.tweetId, - replyto: [], + replyto: const [], userHandle: widget.username, isARepost: false, reposteruserName: '', @@ -390,11 +387,11 @@ class _AllNotificationsListTileState extends State { ), subtitle: widget.notificationType == 'follow' ? Padding( - padding: EdgeInsetsDirectional.fromSTEB(50, 20, 30, 0), + padding: const EdgeInsetsDirectional.fromSTEB(50, 20, 30, 0), child: Container( width: double.infinity, height: 150, - decoration: BoxDecoration( + decoration: const BoxDecoration( color: Colors.white, ), child: Column( @@ -451,7 +448,7 @@ class _AllNotificationsListTileState extends State { ], ), Padding( - padding: EdgeInsetsDirectional.fromSTEB(0, 8, 0, 0), + padding: const EdgeInsetsDirectional.fromSTEB(0, 8, 0, 0), child: Text( widget.name, style: const TextStyle( @@ -462,7 +459,7 @@ class _AllNotificationsListTileState extends State { ), Text( '@${widget.username}', - style: TextStyle( + style: const TextStyle( color: Color(0xFF3A5771), fontWeight: FontWeight.normal, ), diff --git a/lib/views/profile/edit_profile_screen.dart b/lib/views/profile/edit_profile_screen.dart index 14379503..08c696e3 100644 --- a/lib/views/profile/edit_profile_screen.dart +++ b/lib/views/profile/edit_profile_screen.dart @@ -13,7 +13,6 @@ import 'package:tweaxy/components/custom_date_picker_style.dart'; import 'package:tweaxy/constants.dart'; import 'package:tweaxy/cubits/edit_profile_cubit/edit_profile_cubit.dart'; import 'package:tweaxy/models/user.dart'; -import 'package:tweaxy/services/temp_user.dart'; import 'package:tweaxy/shared/keys/profile_keys.dart'; class EditProfileScreen extends StatefulWidget { @@ -133,8 +132,8 @@ class _EditProfileScreenState extends State { removedAvatar: removedAvatar, removedBanner: removedBanner, token: token); - TempUser.userSetData(context); - Navigator.pop(context); + // TempUser.userSetData(context); + // Navigator.pop(context); }, style: ElevatedButton.styleFrom( backgroundColor: Colors.black, @@ -178,7 +177,7 @@ class _EditProfileScreenState extends State { removedAvatar: removedAvatar, removedBanner: removedBanner, token: token); - TempUser.userSetData(context); + // TempUser.userSetData(context); Navigator.pop(context); }, diff --git a/lib/views/profile/profile_screen.dart b/lib/views/profile/profile_screen.dart index e0a113e8..de21b041 100644 --- a/lib/views/profile/profile_screen.dart +++ b/lib/views/profile/profile_screen.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:developer'; import 'package:animated_snack_bar/animated_snack_bar.dart'; import 'package:blur/blur.dart'; @@ -12,7 +11,6 @@ import 'package:fluttertoast/fluttertoast.dart'; import 'package:intl/intl.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:tabbed_sliverlist/tabbed_sliverlist.dart'; -import 'package:tweaxy/cubits/Tweets/tweet_cubit.dart'; import 'package:tweaxy/services/blocking_user_service.dart'; import 'package:tweaxy/services/mute_user_service.dart'; @@ -51,9 +49,9 @@ class _ProfileScreenState extends State void initState() { // TODO: implement initState super.initState(); - if (widget.id != '') + if (widget.id != '') { id = widget.id; - else { + } else { Future(() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); id = prefs.getString('id')!; @@ -109,8 +107,7 @@ class _ProfileScreenState extends State ); } else { User user = snapshot.data!; - if (!initialized) { - initialized = true; + if (text != 'Edit Profile') { text = user.followedByMe! @@ -119,7 +116,7 @@ class _ProfileScreenState extends State ? 'Follow back' : 'Follow'; } - } + _isUserBlocked = user.blockedByMe!; _isMuted = user.muted!; @@ -454,13 +451,13 @@ class ProfileScreenAppBar extends SliverPersistentHeaderDelegate { duration: const Duration(seconds: 3), builder: ((context) { return Container( - padding: EdgeInsets.all(8), + padding: const EdgeInsets.all(8), decoration: BoxDecoration( color: failure ? Colors.red[100] : Colors.blue[100], border: Border.all( color: Colors.blue[700]!, ), - borderRadius: BorderRadius.all(Radius.circular(20))), + borderRadius: const BorderRadius.all(Radius.circular(20))), width: double.infinity, child: ListTile( title: Text( @@ -537,7 +534,7 @@ class CollapsedAppBarText extends StatelessWidget { Padding( padding: const EdgeInsets.only(top: 5.0), child: Text( - '${NumberFormat.compact().format(postsNumber)} Interactions', + '${NumberFormat.compact().format(postsNumber)} Posts', style: TextStyle( fontWeight: postsNumberTextStyle, fontSize: postsNumberTextSize, diff --git a/lib/views/search_users/search_tweets.dart b/lib/views/search_users/search_tweets.dart index aba881a3..504c0652 100644 --- a/lib/views/search_users/search_tweets.dart +++ b/lib/views/search_users/search_tweets.dart @@ -1,10 +1,9 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:tweaxy/views/search_users/tweets_searched.dart'; class SearchTweets extends StatefulWidget { - SearchTweets({required this.username, required this.id}); + SearchTweets({super.key, required this.username, required this.id}); String username; String id; @override diff --git a/lib/views/search_users/search_users.dart b/lib/views/search_users/search_users.dart index 04008ad8..4086274c 100644 --- a/lib/views/search_users/search_users.dart +++ b/lib/views/search_users/search_users.dart @@ -146,7 +146,7 @@ class _MyPageState extends State { } } catch (error) { _pagingController.error = Container( - child: Center( + child: const Center( child: Text( 'No results found', style: TextStyle(color: Colors.black), diff --git a/lib/views/search_users/tweets_searched.dart b/lib/views/search_users/tweets_searched.dart index 9746d913..918ef853 100644 --- a/lib/views/search_users/tweets_searched.dart +++ b/lib/views/search_users/tweets_searched.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; @@ -12,17 +11,11 @@ import 'package:tweaxy/cubits/updata/updata_cubit.dart'; import 'package:tweaxy/cubits/updata/updata_states.dart'; import 'package:tweaxy/models/followers_model.dart'; import 'package:tweaxy/models/tweet.dart'; -import 'package:tweaxy/models/user.dart'; -import 'package:tweaxy/services/FollowersAndFollwing.dart'; -import 'package:tweaxy/services/follow_user.dart'; import 'package:tweaxy/services/get_search_tweets.dart'; import 'package:tweaxy/services/search_for_users.dart'; -import 'package:tweaxy/services/tweets_services.dart'; import 'package:tweaxy/utilities/tweets_utilities.dart'; import 'package:tweaxy/views/loading_screen.dart'; -import 'package:tweaxy/views/search_users/search_tweets.dart'; import 'package:tweaxy/views/search_users/search_users.dart'; -import 'package:tweaxy/views/splash_screen.dart'; class TweetsSearched extends StatefulWidget { TweetsSearched( @@ -206,7 +199,7 @@ class _TweetsSearchedState extends State _pagingController3.addPageRequestListener((pageKey) { _fetchPage3(pageKey); }); - return LoadingScreen(asyncCall: true); + return const LoadingScreen(asyncCall: true); } else { return Scaffold( appBar: AppBar( @@ -235,7 +228,7 @@ class _TweetsSearchedState extends State style: const TextStyle(color: Colors.black, fontSize: 17), decoration: InputDecoration( filled: true, - fillColor: Color.fromARGB(255, 218, 228, 231), + fillColor: const Color.fromARGB(255, 218, 228, 231), border: OutlineInputBorder( borderRadius: BorderRadius.circular(50), borderSide: BorderSide.none, @@ -325,8 +318,8 @@ class _TweetsSearchedState extends State noItemsFoundIndicatorBuilder: (context) { return Center( child: Text( - 'No results for ${queryTweets}', - style: TextStyle( + 'No results for $queryTweets', + style: const TextStyle( fontSize: 20, fontWeight: FontWeight.bold), ), ); @@ -339,8 +332,9 @@ class _TweetsSearchedState extends State return CustomTweet( isUserBlocked: false, tweet: item, - replyto: [], + replyto: const [], isMuted: false, + tobebold: queryTweets, ); }, ), @@ -359,7 +353,7 @@ class _TweetsSearchedState extends State return Center( child: Text( 'No results for ${queryPeople == '' ? queryTweets : queryPeople}', - style: TextStyle( + style: const TextStyle( fontSize: 20, fontWeight: FontWeight.bold), ), ); diff --git a/lib/views/settings/mutes_and_blocks/blocked_users_screen.dart b/lib/views/settings/mutes_and_blocks/blocked_users_screen.dart index 2d09a021..12a81af7 100644 --- a/lib/views/settings/mutes_and_blocks/blocked_users_screen.dart +++ b/lib/views/settings/mutes_and_blocks/blocked_users_screen.dart @@ -1,4 +1,3 @@ -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -12,7 +11,6 @@ import 'package:tweaxy/models/user.dart'; import 'package:tweaxy/services/blocking_user_service.dart'; import 'package:tweaxy/services/follow_user.dart'; import 'package:tweaxy/services/get_blocked_users.dart'; -import 'package:tweaxy/services/unfollow_user.dart'; import 'package:tweaxy/views/notifications/notification_screen.dart'; import 'package:tweaxy/views/profile/profile_screen.dart'; diff --git a/lib/views/settings/mutes_and_blocks/mute_and_blocks_screen.dart b/lib/views/settings/mutes_and_blocks/mute_and_blocks_screen.dart index f24359eb..b7c7e531 100644 --- a/lib/views/settings/mutes_and_blocks/mute_and_blocks_screen.dart +++ b/lib/views/settings/mutes_and_blocks/mute_and_blocks_screen.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:tweaxy/components/AppBar/settings_appbar.dart'; import 'package:tweaxy/components/transition/custom_page_route.dart'; -import 'package:tweaxy/constants.dart'; import 'package:tweaxy/views/settings/mutes_and_blocks/blocked_users_screen.dart'; import 'package:tweaxy/views/settings/mutes_and_blocks/muted_users_screen.dart'; @@ -11,7 +10,7 @@ class MuteAndBlockScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: SettingsAppBar( + appBar: const SettingsAppBar( title: "Mute and block", ), body: Column( diff --git a/lib/views/settings/mutes_and_blocks/muted_users_screen.dart b/lib/views/settings/mutes_and_blocks/muted_users_screen.dart index 1635efd0..f051137e 100644 --- a/lib/views/settings/mutes_and_blocks/muted_users_screen.dart +++ b/lib/views/settings/mutes_and_blocks/muted_users_screen.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:tweaxy/components/transition/custom_page_route.dart'; -import 'package:tweaxy/constants.dart'; import 'package:tweaxy/models/user.dart'; import 'package:tweaxy/services/blocking_user_service.dart'; import 'package:tweaxy/services/follow_user.dart'; @@ -276,7 +275,7 @@ class _MutedUserListTileState extends State { ], ), titleAlignment: ListTileTitleAlignment.top, - subtitle: Text( + subtitle: const Text( 'akfnaofknsoaifnsainf asjif s asf a sf asf asfaifj asijf sah fajshf uash fuhas fuhas fuh as asinfoiasfn ia sf i', style: TextStyle( color: Colors.black54, @@ -285,6 +284,5 @@ class _MutedUserListTileState extends State { maxLines: 2, ), ); - ; } } diff --git a/lib/views/settings/mutes_and_blocks/settings_privacy_safety_screen.dart b/lib/views/settings/mutes_and_blocks/settings_privacy_safety_screen.dart index dc81b62e..d3ca0984 100644 --- a/lib/views/settings/mutes_and_blocks/settings_privacy_safety_screen.dart +++ b/lib/views/settings/mutes_and_blocks/settings_privacy_safety_screen.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:tweaxy/components/AppBar/settings_appbar.dart'; import 'package:tweaxy/components/settings/update_email_components/custom_data_display.dart'; import 'package:tweaxy/components/transition/custom_page_route.dart'; -import 'package:tweaxy/constants.dart'; import 'package:tweaxy/views/settings/mutes_and_blocks/mute_and_blocks_screen.dart'; class SettingsPrivacySafetyScreen extends StatelessWidget { diff --git a/lib/views/settings/settings_and_privacy_view.dart b/lib/views/settings/settings_and_privacy_view.dart index 8514fc48..a8175d03 100644 --- a/lib/views/settings/settings_and_privacy_view.dart +++ b/lib/views/settings/settings_and_privacy_view.dart @@ -1,9 +1,8 @@ -import 'package:crypto/crypto.dart'; import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; import 'package:oktoast/oktoast.dart'; +import 'package:tweaxy/constants.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:tweaxy/components/AppBar/settings_appbar.dart'; import 'package:tweaxy/components/settings/update_email_components/custom_data_display.dart'; @@ -17,7 +16,7 @@ import 'package:tweaxy/views/settings/mutes_and_blocks/settings_privacy_safety_s import 'package:tweaxy/views/settings/settings_view.dart'; class SettingsAndPrivacyView extends StatefulWidget { - SettingsAndPrivacyView({super.key}); + const SettingsAndPrivacyView({super.key}); @override State createState() => _SettingsAndPrivacyViewState(); @@ -28,23 +27,37 @@ class _SettingsAndPrivacyViewState extends State { Future setNotificationSettings() async { SharedPreferences prefs = await SharedPreferences.getInstance(); - deviceToken = prefs.getString("notificationTokenSent"); - String response = await NotificationSettingsService(Dio()) - .notificatioCheckState(deviceToken!); - // String response = "true"; - if (response == "true") { - setState(() { - notiifcationEnable = true; - }); - } else if (response == "false") { - setState(() { - notiifcationEnable = false; - }); - } else { + try { + deviceToken = prefs.getString("notificationTokenSent"); + dynamic response = await NotificationSettingsService(Dio()) + .notificatioCheckState(deviceToken!); + // String response = "true"; + if (response is String) { + SharedPreferences preferences = await SharedPreferences.getInstance(); + await preferences.clear(); + if (mounted) { + Navigator.popUntil(context, (route) => route.isFirst); + Navigator.pushReplacementNamed(context, kSplashScreen); + } + showToastWidget( + const CustomToast(message: "Error in user data"), + position: ToastPosition.bottom, + duration: const Duration(seconds: 5), + ); + } else { + if (response.data["data"]["status"] == "enabled") { + setState(() { + notiifcationEnable = true; + }); + } else if (response.data["data"]["status"] == "disabled") { + setState(() { + notiifcationEnable = false; + }); + } + } + } on Exception catch (e) { showToastWidget( - CustomToast( - message: - "error in loading notification settings state error\n$response"), + CustomToast(message: e.toString()), position: ToastPosition.bottom, duration: const Duration(seconds: 2), ); @@ -56,7 +69,15 @@ class _SettingsAndPrivacyViewState extends State { void initState() { // TODO: implement initState super.initState(); - Future(() async => await setNotificationSettings()); + try { + Future(() async => await setNotificationSettings()); + } on Exception catch (e) { + showToastWidget( + CustomToast(message: e.toString()), + position: ToastPosition.bottom, + duration: const Duration(seconds: 2), + ); + } } @override diff --git a/lib/views/settings/update_email/accout_info.dart b/lib/views/settings/update_email/accout_info.dart index 097949fb..05e2aa5d 100644 --- a/lib/views/settings/update_email/accout_info.dart +++ b/lib/views/settings/update_email/accout_info.dart @@ -43,7 +43,7 @@ class _AccountIfoViewState extends State { context, CustomPageRoute( direction: AxisDirection.left, - child: UpdateUsernameView())); + child: const UpdateUsernameView())); }, title: "Username", subtitle: TempUser.username, diff --git a/lib/views/settings/update_password_view.dart b/lib/views/settings/update_password_view.dart index f3a612a7..299420da 100644 --- a/lib/views/settings/update_password_view.dart +++ b/lib/views/settings/update_password_view.dart @@ -81,6 +81,7 @@ class _UpdatePasswordViewState extends State { onPressed: () async { try { dynamic response = await service.updatePassword( + null, oldPassword: currentPasswordController.text, newPassword: newPasswordController.text, confirmPassword: confirmPasswordController.text); diff --git a/lib/views/settings/web/email_update_web.dart b/lib/views/settings/web/email_update_web.dart index 6fe1920c..70268575 100644 --- a/lib/views/settings/web/email_update_web.dart +++ b/lib/views/settings/web/email_update_web.dart @@ -64,7 +64,7 @@ class _EmailUpdateWebState extends State { onTap: () { showDialog( context: context, - builder: (context) => DialogVerifyPassword( + builder: (context) => const DialogVerifyPassword( ), barrierColor: const Color.fromARGB(100, 97, 119, 129), diff --git a/lib/views/settings/web/update_password_web_view.dart b/lib/views/settings/web/update_password_web_view.dart index a301cda3..2ab9c286 100644 --- a/lib/views/settings/web/update_password_web_view.dart +++ b/lib/views/settings/web/update_password_web_view.dart @@ -107,6 +107,7 @@ class _UpdatePasswordWebViewState extends State { onPressed: () async { try { dynamic response = await service.updatePassword( + null, oldPassword: currentPasswordController.text, newPassword: newPasswordController.text, confirmPassword: confirmPasswordController.text); diff --git a/lib/views/settings/web/update_username_web_view.dart b/lib/views/settings/web/update_username_web_view.dart index 53d9e3a0..e3116ea6 100644 --- a/lib/views/settings/web/update_username_web_view.dart +++ b/lib/views/settings/web/update_username_web_view.dart @@ -97,7 +97,7 @@ class _UpdaateUsernameWebViewState extends State { isButtonEnabled: isButtonEnabled, onPressed: () async { try { - dynamic response = await service.updateUsername(usernameController.text); + dynamic response = await service.updateUsername(null,usernameController.text); if (response is String) { showToastWidget( diff --git a/lib/views/splash_screen.dart b/lib/views/splash_screen.dart index ef6bc5c5..21f44adf 100644 --- a/lib/views/splash_screen.dart +++ b/lib/views/splash_screen.dart @@ -5,10 +5,6 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:tweaxy/constants.dart'; import 'package:flutter/foundation.dart' show kIsWeb; -import 'package:tweaxy/helpers/firebase_api.dart'; -import 'package:tweaxy/services/get_unseen_notification_count.dart'; -import 'package:tweaxy/services/send_device_token.dart'; -import 'package:tweaxy/services/temp_user.dart'; class SplashScreen extends StatefulWidget { const SplashScreen({super.key}); diff --git a/lib/views/trends/trending_screen.dart b/lib/views/trends/trending_screen.dart index eba7f60b..feaa0864 100644 --- a/lib/views/trends/trending_screen.dart +++ b/lib/views/trends/trending_screen.dart @@ -44,7 +44,12 @@ class _TrendingScreenState extends State { _pagingController.appendPage(newItems, nextPageKey); } } catch (error) { - _pagingController.error = error; + _pagingController.error = const Center( + child: Text( + 'No trends found', + style: TextStyle(color: Colors.black), + ), + ); } setState(() {}); } diff --git a/lib/views/trends/tweets_trend_list.dart b/lib/views/trends/tweets_trend_list.dart index c480fa81..4bcb9ed0 100644 --- a/lib/views/trends/tweets_trend_list.dart +++ b/lib/views/trends/tweets_trend_list.dart @@ -33,6 +33,7 @@ class _MyPageState extends State { }); } + @override void dispose() { super.dispose(); diff --git a/pubspec.lock b/pubspec.lock index aa44533b..aa23f37e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -6,7 +6,7 @@ packages: description: name: _fe_analyzer_shared sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "64.0.0" _flutterfire_internals: @@ -14,7 +14,7 @@ packages: description: name: _flutterfire_internals sha256: f5628cd9c92ed11083f425fd1f8f1bc60ecdda458c81d73b143aeda036c35fe7 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.3.16" analyzer: @@ -22,7 +22,7 @@ packages: description: name: analyzer sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "6.2.0" animated_snack_bar: @@ -30,7 +30,7 @@ packages: description: name: animated_snack_bar sha256: "9ec2d79507546f65b82038c9ac5ddfc3c2fccf285def43070606b0ec0fc56d34" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.4.0" any_link_preview: @@ -38,7 +38,7 @@ packages: description: name: any_link_preview sha256: be2adb74944140428c46c3688c1b843c884ead6908e13e8cae359fa31f37cf07 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.0.1" args: @@ -46,7 +46,7 @@ packages: description: name: args sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.4.2" async: @@ -54,7 +54,7 @@ packages: description: name: async sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.11.0" audio_waveforms: @@ -62,7 +62,7 @@ packages: description: name: audio_waveforms sha256: f2f81e256c5c03b64e2861e0323a77e1b6790c256c73393b671214c9846260fc - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.4" auto_size_text: @@ -70,7 +70,7 @@ packages: description: name: auto_size_text sha256: "3f5261cd3fb5f2a9ab4e2fc3fba84fd9fcaac8821f20a1d4e71f557521b22599" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.0.0" bloc: @@ -78,7 +78,7 @@ packages: description: name: bloc sha256: "3820f15f502372d979121de1f6b97bfcf1630ebff8fe1d52fb2b0bfa49be5b49" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "8.1.2" blur: @@ -86,7 +86,7 @@ packages: description: name: blur sha256: fd23f1247faee4a7d1a3efb6b7c3cea134f3b939d72e5f8d45233deb0776259f - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.1.0" boolean_selector: @@ -94,7 +94,7 @@ packages: description: name: boolean_selector sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.1" cached_network_image: @@ -102,7 +102,7 @@ packages: description: name: cached_network_image sha256: f98972704692ba679db144261172a8e20feb145636c617af0eb4022132a6797f - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.3.0" cached_network_image_platform_interface: @@ -110,7 +110,7 @@ packages: description: name: cached_network_image_platform_interface sha256: "56aa42a7a01e3c9db8456d9f3f999931f1e05535b5a424271e9a38cabf066613" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.0.0" cached_network_image_web: @@ -118,7 +118,7 @@ packages: description: name: cached_network_image_web sha256: "759b9a9f8f6ccbb66c185df805fac107f05730b1dab9c64626d1008cca532257" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.1.0" characters: @@ -126,7 +126,7 @@ packages: description: name: characters sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.3.0" chatview: @@ -134,7 +134,7 @@ packages: description: name: chatview sha256: "691bf1249798d9bf820ae7276a0d2378871a7e2d639a9b384a6148d7f1609000" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.3.1" chewie: @@ -142,7 +142,7 @@ packages: description: name: chewie sha256: "3427e469d7cc99536ac4fbaa069b3352c21760263e65ffb4f0e1c054af43a73e" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.7.4" clock: @@ -150,7 +150,7 @@ packages: description: name: clock sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.1.1" collection: @@ -158,7 +158,7 @@ packages: description: name: collection sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.18.0" convert: @@ -166,7 +166,7 @@ packages: description: name: convert sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.1.1" coverage: @@ -174,7 +174,7 @@ packages: description: name: coverage sha256: "595a29b55ce82d53398e1bcc2cba525d7bd7c59faeb2d2540e9d42c390cfeeeb" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.6.4" cross_file: @@ -182,7 +182,7 @@ packages: description: name: cross_file sha256: fedaadfa3a6996f75211d835aaeb8fede285dae94262485698afd832371b9a5e - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.3.3+8" crypto: @@ -190,7 +190,7 @@ packages: description: name: crypto sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.0.3" csslib: @@ -198,7 +198,7 @@ packages: description: name: csslib sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.0" cupertino_icons: @@ -206,7 +206,7 @@ packages: description: name: cupertino_icons sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.6" dash_chat_2: @@ -214,7 +214,7 @@ packages: description: name: dash_chat_2 sha256: "1bccbeab1289a2f08c39ee00f5bb073ee13916401c6c79829688f3d029cf7e11" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.0.19" datepicker_dropdown: @@ -222,7 +222,7 @@ packages: description: name: datepicker_dropdown sha256: "790ccd8c4a9464a24245ae80e4fcfb03cc449675e2485100db68713e25638e14" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.0.9" dbus: @@ -230,7 +230,7 @@ packages: description: name: dbus sha256: "365c771ac3b0e58845f39ec6deebc76e3276aa9922b0cc60840712094d9047ac" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.7.10" dio: @@ -238,7 +238,7 @@ packages: description: name: dio sha256: "797e1e341c3dd2f69f2dad42564a6feff3bfb87187d05abb93b9609e6f1645c3" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "5.4.0" dotted_border: @@ -246,7 +246,7 @@ packages: description: name: dotted_border sha256: "108837e11848ca776c53b30bc870086f84b62ed6e01c503ed976e8f8c7df9c04" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.0" dropdown_button2: @@ -254,7 +254,7 @@ packages: description: name: dropdown_button2 sha256: b0fe8d49a030315e9eef6c7ac84ca964250155a6224d491c1365061bc974a9e1 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.3.9" dropdown_search: @@ -262,7 +262,7 @@ packages: description: name: dropdown_search sha256: "55106e8290acaa97ed15bea1fdad82c3cf0c248dd410e651f5a8ac6870f783ab" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "5.0.6" emoji_picker_flutter: @@ -270,7 +270,7 @@ packages: description: name: emoji_picker_flutter sha256: "009c51efc763d5a6ba05a5628b8b2184c327cd117d66ea9c3e7edf2ff269c423" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.6.3" endless: @@ -278,7 +278,7 @@ packages: description: name: endless sha256: "2016ce4df3cb44ac8ea505207b8954f46a3400ce8ba8026a914607499cae3bb2" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.6.3" fake_async: @@ -286,7 +286,7 @@ packages: description: name: fake_async sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.3.1" ffi: @@ -294,7 +294,7 @@ packages: description: name: ffi sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.0" file: @@ -302,7 +302,7 @@ packages: description: name: file sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "6.1.4" file_selector_linux: @@ -310,7 +310,7 @@ packages: description: name: file_selector_linux sha256: "045d372bf19b02aeb69cacf8b4009555fb5f6f0b7ad8016e5f46dd1387ddd492" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.9.2+1" file_selector_macos: @@ -318,7 +318,7 @@ packages: description: name: file_selector_macos sha256: b15c3da8bd4908b9918111fa486903f5808e388b8d1c559949f584725a6594d6 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.9.3+3" file_selector_platform_interface: @@ -326,7 +326,7 @@ packages: description: name: file_selector_platform_interface sha256: "0aa47a725c346825a2bd396343ce63ac00bda6eff2fbc43eabe99737dede8262" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.6.1" file_selector_windows: @@ -334,7 +334,7 @@ packages: description: name: file_selector_windows sha256: d3547240c20cabf205c7c7f01a50ecdbc413755814d6677f3cb366f04abcead0 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.9.3+1" firebase_auth: @@ -342,7 +342,7 @@ packages: description: name: firebase_auth sha256: "88f88d541a2c1903c023355e13d077835573a200bbf57e12a6a2c24bf99665a1" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "4.15.3" firebase_auth_platform_interface: @@ -350,7 +350,7 @@ packages: description: name: firebase_auth_platform_interface sha256: "3c9cfaccb7549492edf5b0c67c6dd1c6727c7830891aa6727f2fb225f0226626" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "7.0.9" firebase_auth_web: @@ -358,7 +358,7 @@ packages: description: name: firebase_auth_web sha256: c09515414c07c11bb133aec4baae9a74c6ff1f62bf05ace54564db82b8c87852 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "5.8.12" firebase_core: @@ -366,7 +366,7 @@ packages: description: name: firebase_core sha256: "96607c0e829a581c2a483c658f04e8b159964c3bae2730f73297070bc85d40bb" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.24.2" firebase_core_platform_interface: @@ -374,7 +374,7 @@ packages: description: name: firebase_core_platform_interface sha256: c437ae5d17e6b5cc7981cf6fd458a5db4d12979905f9aafd1fea930428a9fe63 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "5.0.0" firebase_core_web: @@ -382,7 +382,7 @@ packages: description: name: firebase_core_web sha256: d585bdf3c656c3f7821ba1bd44da5f13365d22fcecaf5eb75c4295246aaa83c0 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.10.0" firebase_messaging: @@ -390,7 +390,7 @@ packages: description: name: firebase_messaging sha256: "199fe8186a5370d1cf5ce0819191079afc305914e8f38715f5e23943940dfe2d" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "14.7.9" firebase_messaging_platform_interface: @@ -398,7 +398,7 @@ packages: description: name: firebase_messaging_platform_interface sha256: "54e283a0e41d81d854636ad0dad73066adc53407a60a7c3189c9656e2f1b6107" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "4.5.18" firebase_messaging_web: @@ -406,7 +406,7 @@ packages: description: name: firebase_messaging_web sha256: "90dc7ed885e90a24bb0e56d661d4d2b5f84429697fd2cbb9e5890a0ca370e6f4" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.5.18" flutter: @@ -419,7 +419,7 @@ packages: description: name: flutter_bloc sha256: e74efb89ee6945bcbce74a5b3a5a3376b088e5f21f55c263fc38cbdc6237faae - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "8.1.3" flutter_cache_manager: @@ -427,7 +427,7 @@ packages: description: name: flutter_cache_manager sha256: "8207f27539deb83732fdda03e259349046a39a4c767269285f449ade355d54ba" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.3.1" flutter_driver: @@ -440,7 +440,7 @@ packages: description: name: flutter_holo_date_picker sha256: "839ac788e468c8c51a280b3847e4d56e6286bef3a823ba2e81a304564ec59822" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.1.3" flutter_keyboard_visibility: @@ -448,7 +448,7 @@ packages: description: name: flutter_keyboard_visibility sha256: "4983655c26ab5b959252ee204c2fffa4afeb4413cd030455194ec0caa3b8e7cb" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "5.4.1" flutter_keyboard_visibility_linux: @@ -456,7 +456,7 @@ packages: description: name: flutter_keyboard_visibility_linux sha256: "6fba7cd9bb033b6ddd8c2beb4c99ad02d728f1e6e6d9b9446667398b2ac39f08" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.0" flutter_keyboard_visibility_macos: @@ -464,7 +464,7 @@ packages: description: name: flutter_keyboard_visibility_macos sha256: c5c49b16fff453dfdafdc16f26bdd8fb8d55812a1d50b0ce25fc8d9f2e53d086 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.0" flutter_keyboard_visibility_platform_interface: @@ -472,7 +472,7 @@ packages: description: name: flutter_keyboard_visibility_platform_interface sha256: e43a89845873f7be10cb3884345ceb9aebf00a659f479d1c8f4293fcb37022a4 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.0.0" flutter_keyboard_visibility_web: @@ -480,7 +480,7 @@ packages: description: name: flutter_keyboard_visibility_web sha256: d3771a2e752880c79203f8d80658401d0c998e4183edca05a149f5098ce6e3d1 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.0.0" flutter_keyboard_visibility_windows: @@ -488,7 +488,7 @@ packages: description: name: flutter_keyboard_visibility_windows sha256: fc4b0f0b6be9b93ae527f3d527fb56ee2d918cd88bbca438c478af7bcfd0ef73 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.0" flutter_linkify: @@ -496,7 +496,7 @@ packages: description: name: flutter_linkify sha256: "74669e06a8f358fee4512b4320c0b80e51cffc496607931de68d28f099254073" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "6.0.0" flutter_lints: @@ -504,7 +504,7 @@ packages: description: name: flutter_lints sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.0.3" flutter_parsed_text: @@ -512,7 +512,7 @@ packages: description: name: flutter_parsed_text sha256: "529cf5793b7acdf16ee0f97b158d0d4ba0bf06e7121ef180abe1a5b59e32c1e2" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.2.1" flutter_plugin_android_lifecycle: @@ -520,7 +520,7 @@ packages: description: name: flutter_plugin_android_lifecycle sha256: b068ffc46f82a55844acfa4fdbb61fad72fa2aef0905548419d97f0f95c456da - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.0.17" flutter_speed_dial: @@ -528,7 +528,7 @@ packages: description: name: flutter_speed_dial sha256: "698a037274a66dbae8697c265440e6acb6ab6cae9ac5f95c749e7944d8f28d41" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "7.0.0" flutter_spinkit: @@ -536,7 +536,7 @@ packages: description: name: flutter_spinkit sha256: b39c753e909d4796906c5696a14daf33639a76e017136c8d82bf3e620ce5bb8e - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "5.2.0" flutter_staggered_grid_view: @@ -544,7 +544,7 @@ packages: description: name: flutter_staggered_grid_view sha256: "19e7abb550c96fbfeb546b23f3ff356ee7c59a019a651f8f102a4ba9b7349395" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.7.0" flutter_svg: @@ -552,7 +552,7 @@ packages: description: name: flutter_svg sha256: d39e7f95621fc84376bc0f7d504f05c3a41488c562f4a8ad410569127507402c - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.0.9" flutter_test: @@ -565,7 +565,7 @@ packages: description: name: flutter_typeahead sha256: "1f6b248bb4f3ebb4cf1ee0354aa23c77be457fb2d26d6847ecc33a917f65e58e" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "5.0.1" flutter_web_plugins: @@ -578,7 +578,7 @@ packages: description: name: fluttertoast sha256: dfdde255317af381bfc1c486ed968d5a43a2ded9c931e87cbecd88767d6a71c1 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "8.2.4" font_awesome_flutter: @@ -586,7 +586,7 @@ packages: description: name: font_awesome_flutter sha256: "52671aea66da73b58d42ec6d0912b727a42248dd9a7c76d6c20f275783c48c08" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "10.6.0" frontend_server_client: @@ -594,7 +594,7 @@ packages: description: name: frontend_server_client sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.2.0" fuchsia_remote_debug_protocol: @@ -607,7 +607,7 @@ packages: description: name: get sha256: e4e7335ede17452b391ed3b2ede016545706c01a02292a6c97619705e7d2a85e - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "4.6.6" glob: @@ -615,7 +615,7 @@ packages: description: name: glob sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.2" google_fonts: @@ -623,7 +623,7 @@ packages: description: name: google_fonts sha256: f0b8d115a13ecf827013ec9fc883390ccc0e87a96ed5347a3114cac177ef18e8 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "6.1.0" google_identity_services_web: @@ -631,7 +631,7 @@ packages: description: name: google_identity_services_web sha256: "0c56c2c5d60d6dfaf9725f5ad4699f04749fb196ee5a70487a46ef184837ccf6" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.3.0+2" google_sign_in: @@ -639,7 +639,7 @@ packages: description: name: google_sign_in sha256: "0b8787cb9c1a68ad398e8010e8c8766bfa33556d2ab97c439fb4137756d7308f" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "6.2.1" google_sign_in_android: @@ -647,7 +647,7 @@ packages: description: name: google_sign_in_android sha256: "6031f59074a337fdd81be821aba84cee3a41338c6e958499a5cd34d3e1db80ef" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "6.1.20" google_sign_in_ios: @@ -655,7 +655,7 @@ packages: description: name: google_sign_in_ios sha256: "0822b0abc94ff6d705d7a321ef58818ffed864787f23f5ac3451e3e6afbcf90d" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "5.7.1" google_sign_in_platform_interface: @@ -663,7 +663,7 @@ packages: description: name: google_sign_in_platform_interface sha256: e10eaaa30a0cb03af12dd324fb2e630ac7e9d854d0530f7a87a4d825031f9a4a - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.4.3" google_sign_in_web: @@ -671,7 +671,7 @@ packages: description: name: google_sign_in_web sha256: "38e6ec2a7d65ec34bb7ae2db64a1d042b021330433b999e87330d45c688ff549" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.12.3+1" grouped_list: @@ -679,7 +679,7 @@ packages: description: name: grouped_list sha256: fef106470186081c32636aa055492eee7fc7fe8bf0921a48d31ded24821af19f - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "5.1.2" hidable: @@ -687,7 +687,7 @@ packages: description: name: hidable sha256: "72ffcc3dbaa736f072b3530711088e9da5acfda02df275287c76f88ae81877b4" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.6" html: @@ -695,7 +695,7 @@ packages: description: name: html sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.15.4" http: @@ -703,7 +703,7 @@ packages: description: name: http sha256: d4872660c46d929f6b8a9ef4e7a7eff7e49bbf0c4ec3f385ee32df5119175139 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.1.2" http_multi_server: @@ -711,7 +711,7 @@ packages: description: name: http_multi_server sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.2.1" http_parser: @@ -719,7 +719,7 @@ packages: description: name: http_parser sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "4.0.2" icon_decoration: @@ -727,7 +727,7 @@ packages: description: name: icon_decoration sha256: f2b8be923906bd1d73a3ab02155a863f5bd4fc23b04c6ecb32bbc005b43eb9e1 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.0.2" image_cropper: @@ -735,7 +735,7 @@ packages: description: name: image_cropper sha256: f4bad5ed2dfff5a7ce0dfbad545b46a945c702bb6182a921488ef01ba7693111 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "5.0.1" image_cropper_for_web: @@ -743,7 +743,7 @@ packages: description: name: image_cropper_for_web sha256: "865d798b5c9d826f1185b32e5d0018c4183ddb77b7b82a931e1a06aa3b74974e" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.0.0" image_cropper_platform_interface: @@ -751,7 +751,7 @@ packages: description: name: image_cropper_platform_interface sha256: ee160d686422272aa306125f3b6fb1c1894d9b87a5e20ed33fa008e7285da11e - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "5.0.0" image_downloader: @@ -768,7 +768,7 @@ packages: description: name: image_picker sha256: fc712337719239b0b6e41316aa133350b078fa39b6cbd706b61f3fd421b03c77 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.5" image_picker_android: @@ -776,7 +776,7 @@ packages: description: name: image_picker_android sha256: ecdc963d2aa67af5195e723a40580f802d4392e31457a12a562b3e2bd6a396fe - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.8.9+1" image_picker_for_web: @@ -784,7 +784,7 @@ packages: description: name: image_picker_for_web sha256: "50bc9ae6a77eea3a8b11af5eb6c661eeb858fdd2f734c2a4fd17086922347ef7" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.0.1" image_picker_ios: @@ -792,7 +792,7 @@ packages: description: name: image_picker_ios sha256: eac0a62104fa12feed213596df0321f57ce5a572562f72a68c4ff81e9e4caacf - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.8.9" image_picker_linux: @@ -800,7 +800,7 @@ packages: description: name: image_picker_linux sha256: "4ed1d9bb36f7cd60aa6e6cd479779cc56a4cb4e4de8f49d487b1aaad831300fa" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.2.1+1" image_picker_macos: @@ -808,7 +808,7 @@ packages: description: name: image_picker_macos sha256: "3f5ad1e8112a9a6111c46d0b57a7be2286a9a07fc6e1976fdf5be2bd31d4ff62" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.2.1+1" image_picker_platform_interface: @@ -816,7 +816,7 @@ packages: description: name: image_picker_platform_interface sha256: ed9b00e63977c93b0d2d2b343685bed9c324534ba5abafbb3dfbd6a780b1b514 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.9.1" image_picker_windows: @@ -824,7 +824,7 @@ packages: description: name: image_picker_windows sha256: "6ad07afc4eb1bc25f3a01084d28520496c4a3bb0cb13685435838167c9dcedeb" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.2.1+1" infinite_scroll_pagination: @@ -832,7 +832,7 @@ packages: description: name: infinite_scroll_pagination sha256: b68bce20752fcf36c7739e60de4175494f74e99e9a69b4dd2fe3a1dd07a7f16a - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "4.0.0" integration_test: @@ -845,7 +845,7 @@ packages: description: name: intl sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.18.1" io: @@ -853,7 +853,7 @@ packages: description: name: io sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.4" js: @@ -861,7 +861,7 @@ packages: description: name: js sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.6.7" like_button: @@ -869,7 +869,7 @@ packages: description: name: like_button sha256: "08e6a45b78888412df5d351786c550205ad3a677e72a0820d5bbc0b063c8a463" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.0.5" linkify: @@ -877,7 +877,7 @@ packages: description: name: linkify sha256: "4139ea77f4651ab9c315b577da2dd108d9aa0bd84b5d03d33323f1970c645832" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "5.0.0" lints: @@ -885,7 +885,7 @@ packages: description: name: lints sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.1" loading_indicator: @@ -893,7 +893,7 @@ packages: description: name: loading_indicator sha256: a101ffb2aa3e646137d7810bfa90b50525dd3f72c01235b6df7491cf6af6f284 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.1.1" logging: @@ -901,7 +901,7 @@ packages: description: name: logging sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.2.0" matcher: @@ -909,7 +909,7 @@ packages: description: name: matcher sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.12.16" material_color_utilities: @@ -917,7 +917,7 @@ packages: description: name: material_color_utilities sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.5.0" material_floating_search_bar_2: @@ -925,7 +925,7 @@ packages: description: name: material_floating_search_bar_2 sha256: ab0c6d209d9491f98dd4c72f2641d0ba1dd35c87effca1f23d8679bece43add0 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.5.0" meta: @@ -933,7 +933,7 @@ packages: description: name: meta sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.10.0" mime: @@ -941,7 +941,7 @@ packages: description: name: mime sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.4" modal_progress_hud_nsn: @@ -949,7 +949,7 @@ packages: description: name: modal_progress_hud_nsn sha256: "0b0d95e5ce3e1884390624fbe79fcf90d7de10abe05d26c0e276c25e7130e3e0" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.4.0" multi_image_layout: @@ -957,7 +957,7 @@ packages: description: name: multi_image_layout sha256: "41a529a388f0a12c257f24a3b750a954255ebf7411102efe4a20b07e63e2f79e" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.0.2" multi_video_player: @@ -965,7 +965,7 @@ packages: description: name: multi_video_player sha256: "27e239a8af73816ccca32f8e4ff09c5a9b152483bc749df5218dac7079a5a030" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.0.5" nested: @@ -973,7 +973,7 @@ packages: description: name: nested sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.0" node_preamble: @@ -981,7 +981,7 @@ packages: description: name: node_preamble sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.0.2" octo_image: @@ -989,7 +989,7 @@ packages: description: name: octo_image sha256: "45b40f99622f11901238e18d48f5f12ea36426d8eced9f4cbf58479c7aa2430d" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.0.0" oktoast: @@ -997,7 +997,7 @@ packages: description: name: oktoast sha256: f1366c5c793ddfb8f55bc6fc3e45db43c45debf173b765fb4c5ec096cbdeb84a - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.4.0" package_config: @@ -1005,7 +1005,7 @@ packages: description: name: package_config sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.0" package_info_plus: @@ -1013,7 +1013,7 @@ packages: description: name: package_info_plus sha256: "88bc797f44a94814f2213db1c9bd5badebafdfb8290ca9f78d4b9ee2a3db4d79" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "5.0.1" package_info_plus_platform_interface: @@ -1021,7 +1021,7 @@ packages: description: name: package_info_plus_platform_interface sha256: "9bc8ba46813a4cc42c66ab781470711781940780fd8beddd0c3da62506d3a6c6" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.0.1" paginated_search_bar: @@ -1029,7 +1029,7 @@ packages: description: name: paginated_search_bar sha256: "61ad88426b55586e688b7f650a57f560b04ea8f89fd57fbb52aafa62b007dd97" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.1.2" path: @@ -1037,7 +1037,7 @@ packages: description: name: path sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.8.3" path_drawing: @@ -1045,7 +1045,7 @@ packages: description: name: path_drawing sha256: bbb1934c0cbb03091af082a6389ca2080345291ef07a5fa6d6e078ba8682f977 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.1" path_parsing: @@ -1053,7 +1053,7 @@ packages: description: name: path_parsing sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.1" path_provider: @@ -1061,23 +1061,23 @@ packages: description: name: path_provider sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.1" path_provider_android: dependency: transitive description: name: path_provider_android - sha256: e595b98692943b4881b219f0a9e3945118d3c16bd7e2813f98ec6e532d905f72 - url: "https://pub.flutter-io.cn" + sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668" + url: "https://pub.dev" source: hosted - version: "2.2.1" + version: "2.2.2" path_provider_foundation: dependency: transitive description: name: path_provider_foundation sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.3.1" path_provider_linux: @@ -1085,7 +1085,7 @@ packages: description: name: path_provider_linux sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.2.1" path_provider_platform_interface: @@ -1093,7 +1093,7 @@ packages: description: name: path_provider_platform_interface sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.1" path_provider_windows: @@ -1101,7 +1101,7 @@ packages: description: name: path_provider_windows sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.2.1" petitparser: @@ -1109,7 +1109,7 @@ packages: description: name: petitparser sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "6.0.2" photo_view: @@ -1117,7 +1117,7 @@ packages: description: name: photo_view sha256: "26cb153080a2673bebccaf72d3283e82f8f41a47fe5f9bc5ba8634d2e8a9fc8e" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.13.0" platform: @@ -1125,7 +1125,7 @@ packages: description: name: platform sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.1.2" plugin_platform_interface: @@ -1133,7 +1133,7 @@ packages: description: name: plugin_platform_interface sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.7" pointer_interceptor: @@ -1141,7 +1141,7 @@ packages: description: name: pointer_interceptor sha256: adf7a637f97c077041d36801b43be08559fd4322d2127b3f20bb7be1b9eebc22 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.9.3+7" pool: @@ -1149,7 +1149,7 @@ packages: description: name: pool sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.5.1" popover: @@ -1157,7 +1157,7 @@ packages: description: name: popover sha256: "6a0928ccdcf12d46b407372b644a0d94400b316d0ee072a19dcef03c2bb88c3f" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.2.9" popup_menu: @@ -1165,7 +1165,7 @@ packages: description: name: popup_menu sha256: a6d7f39669cd010818063233f287822d4fcfcdc1d872b4bae72d9f3caf848e3a - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.0.0" preload_page_view: @@ -1173,7 +1173,7 @@ packages: description: name: preload_page_view sha256: "488a10c158c5c2e9ba9d77e5dbc09b1e49e37a20df2301e5ba02992eac802b7a" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.2.0" process: @@ -1181,7 +1181,7 @@ packages: description: name: process sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "4.2.4" progress_indicators: @@ -1189,7 +1189,7 @@ packages: description: name: progress_indicators sha256: "28cba16c2c1f37b14f3551c406e0d9b156fb2f3205d7b4e4153823b3abc9d56c" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.0" provider: @@ -1197,7 +1197,7 @@ packages: description: name: provider sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "6.1.1" pub_semver: @@ -1205,7 +1205,7 @@ packages: description: name: pub_semver sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.4" rxdart: @@ -1213,7 +1213,7 @@ packages: description: name: rxdart sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.27.7" shared_preferences: @@ -1221,7 +1221,7 @@ packages: description: name: shared_preferences sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.2.2" shared_preferences_android: @@ -1229,7 +1229,7 @@ packages: description: name: shared_preferences_android sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.2.1" shared_preferences_foundation: @@ -1237,7 +1237,7 @@ packages: description: name: shared_preferences_foundation sha256: "7bf53a9f2d007329ee6f3df7268fd498f8373602f943c975598bbb34649b62a7" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.3.4" shared_preferences_linux: @@ -1245,7 +1245,7 @@ packages: description: name: shared_preferences_linux sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.3.2" shared_preferences_platform_interface: @@ -1253,7 +1253,7 @@ packages: description: name: shared_preferences_platform_interface sha256: d4ec5fc9ebb2f2e056c617112aa75dcf92fc2e4faaf2ae999caa297473f75d8a - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.3.1" shared_preferences_web: @@ -1261,7 +1261,7 @@ packages: description: name: shared_preferences_web sha256: "7b15ffb9387ea3e237bb7a66b8a23d2147663d391cafc5c8f37b2e7b4bde5d21" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.2.2" shared_preferences_windows: @@ -1269,7 +1269,7 @@ packages: description: name: shared_preferences_windows sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.3.2" shelf: @@ -1277,7 +1277,7 @@ packages: description: name: shelf sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.4.1" shelf_packages_handler: @@ -1285,7 +1285,7 @@ packages: description: name: shelf_packages_handler sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.0.2" shelf_static: @@ -1293,7 +1293,7 @@ packages: description: name: shelf_static sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.1.2" shelf_web_socket: @@ -1301,7 +1301,7 @@ packages: description: name: shelf_web_socket sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.4" sign_button: @@ -1309,7 +1309,7 @@ packages: description: name: sign_button sha256: "03529ce0d98551f76e4cff9a9be35e28bec784a5406da80d087fa043d4625643" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.0.6" sky_engine: @@ -1322,7 +1322,7 @@ packages: description: name: sliver_tools sha256: eae28220badfb9d0559207badcbbc9ad5331aac829a88cb0964d330d2a4636a6 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.2.12" socket_io_client: @@ -1330,7 +1330,7 @@ packages: description: name: socket_io_client sha256: ede469f3e4c55e8528b4e023bdedbc20832e8811ab9b61679d1ba3ed5f01f23b - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.0.3+1" socket_io_common: @@ -1338,7 +1338,7 @@ packages: description: name: socket_io_common sha256: "2ab92f8ff3ebbd4b353bf4a98bee45cc157e3255464b2f90f66e09c4472047eb" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.0.3" source_map_stack_trace: @@ -1346,7 +1346,7 @@ packages: description: name: source_map_stack_trace sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.1" source_maps: @@ -1354,7 +1354,7 @@ packages: description: name: source_maps sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.10.12" source_span: @@ -1362,7 +1362,7 @@ packages: description: name: source_span sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.10.0" sprintf: @@ -1370,7 +1370,7 @@ packages: description: name: sprintf sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "7.0.0" sqflite: @@ -1378,7 +1378,7 @@ packages: description: name: sqflite sha256: "591f1602816e9c31377d5f008c2d9ef7b8aca8941c3f89cc5fd9d84da0c38a9a" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.3.0" sqflite_common: @@ -1386,7 +1386,7 @@ packages: description: name: sqflite_common sha256: bb4738f15b23352822f4c42a531677e5c6f522e079461fd240ead29d8d8a54a6 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.5.0+2" stack_trace: @@ -1394,7 +1394,7 @@ packages: description: name: stack_trace sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.11.1" state_property: @@ -1402,7 +1402,7 @@ packages: description: name: state_property sha256: "9762a86f4f0c30c264734069cc10899a211ab4869a392289ac4eddb8f3dbf6dc" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.1.1" stream_channel: @@ -1410,7 +1410,7 @@ packages: description: name: stream_channel sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.2" string_scanner: @@ -1418,7 +1418,7 @@ packages: description: name: string_scanner sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.2.0" string_validator: @@ -1426,7 +1426,7 @@ packages: description: name: string_validator sha256: "54d4f42cd6878ae72793a58a529d9a18ebfdfbfebd9793bbe55c9b28935e8543" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.2" sync_http: @@ -1434,7 +1434,7 @@ packages: description: name: sync_http sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.3.1" synchronized: @@ -1442,7 +1442,7 @@ packages: description: name: synchronized sha256: "539ef412b170d65ecdafd780f924e5be3f60032a1128df156adad6c5b373d558" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.1.0+1" tabbed_sliverlist: @@ -1450,7 +1450,7 @@ packages: description: name: tabbed_sliverlist sha256: "42dd7f9162bbf1a75a8d0d25747d90bdd5ffb7cdc66430621cd2d8a5fb36637e" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.1.0" term_glyph: @@ -1458,7 +1458,7 @@ packages: description: name: term_glyph sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.2.1" test: @@ -1466,7 +1466,7 @@ packages: description: name: test sha256: a1f7595805820fcc05e5c52e3a231aedd0b72972cb333e8c738a8b1239448b6f - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.24.9" test_api: @@ -1474,7 +1474,7 @@ packages: description: name: test_api sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.6.1" test_core: @@ -1482,7 +1482,7 @@ packages: description: name: test_core sha256: a757b14fc47507060a162cc2530d9a4a2f92f5100a952c7443b5cad5ef5b106a - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.5.9" timeago: @@ -1490,7 +1490,7 @@ packages: description: name: timeago sha256: c44b80cbc6b44627c00d76960f2af571f6f50e5dbedef4d9215d455e4335165b - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.6.0" typed_data: @@ -1498,7 +1498,7 @@ packages: description: name: typed_data sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.3.2" url_launcher: @@ -1506,7 +1506,7 @@ packages: description: name: url_launcher sha256: e9aa5ea75c84cf46b3db4eea212523591211c3cf2e13099ee4ec147f54201c86 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "6.2.2" url_launcher_android: @@ -1514,7 +1514,7 @@ packages: description: name: url_launcher_android sha256: "31222ffb0063171b526d3e569079cf1f8b294075ba323443fdc690842bfd4def" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "6.2.0" url_launcher_ios: @@ -1522,7 +1522,7 @@ packages: description: name: url_launcher_ios sha256: bba3373219b7abb6b5e0d071b0fe66dfbe005d07517a68e38d4fc3638f35c6d3 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "6.2.1" url_launcher_linux: @@ -1530,7 +1530,7 @@ packages: description: name: url_launcher_linux sha256: ab360eb661f8879369acac07b6bb3ff09d9471155357da8443fd5d3cf7363811 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.1.1" url_launcher_macos: @@ -1538,7 +1538,7 @@ packages: description: name: url_launcher_macos sha256: b7244901ea3cf489c5335bdacda07264a6e960b1c1b1a9f91e4bc371d9e68234 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.1.0" url_launcher_platform_interface: @@ -1546,7 +1546,7 @@ packages: description: name: url_launcher_platform_interface sha256: "980e8d9af422f477be6948bdfb68df8433be71f5743a188968b0c1b887807e50" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.2.0" url_launcher_web: @@ -1554,7 +1554,7 @@ packages: description: name: url_launcher_web sha256: "7286aec002c8feecc338cc33269e96b73955ab227456e9fb2a91f7fab8a358e9" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.2.2" url_launcher_windows: @@ -1562,7 +1562,7 @@ packages: description: name: url_launcher_windows sha256: ecf9725510600aa2bb6d7ddabe16357691b6d2805f66216a97d1b881e21beff7 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.1.1" uuid: @@ -1570,7 +1570,7 @@ packages: description: name: uuid sha256: "22c94e5ad1e75f9934b766b53c742572ee2677c56bc871d850a57dad0f82127f" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "4.2.2" vector_graphics: @@ -1578,7 +1578,7 @@ packages: description: name: vector_graphics sha256: "0f0c746dd2d6254a0057218ff980fc7f5670fd0fcf5e4db38a490d31eed4ad43" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.1.9+1" vector_graphics_codec: @@ -1586,7 +1586,7 @@ packages: description: name: vector_graphics_codec sha256: "0edf6d630d1bfd5589114138ed8fada3234deacc37966bec033d3047c29248b7" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.1.9+1" vector_graphics_compiler: @@ -1594,7 +1594,7 @@ packages: description: name: vector_graphics_compiler sha256: d24333727332d9bd20990f1483af4e09abdb9b1fc7c3db940b56ab5c42790c26 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.1.9+1" vector_math: @@ -1602,7 +1602,7 @@ packages: description: name: vector_math sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.4" video_player: @@ -1610,7 +1610,7 @@ packages: description: name: video_player sha256: e16f0a83601a78d165dabc17e4dac50997604eb9e4cc76e10fa219046b70cef3 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.8.1" video_player_android: @@ -1618,7 +1618,7 @@ packages: description: name: video_player_android sha256: "3fe89ab07fdbce786e7eb25b58532d6eaf189ceddc091cb66cba712f8d9e8e55" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.4.10" video_player_avfoundation: @@ -1626,7 +1626,7 @@ packages: description: name: video_player_avfoundation sha256: "01a57940e1dabc8769ccd457c4ae9ea50274e7d5a7617f7820dae5fe1d8436ae" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.5.3" video_player_platform_interface: @@ -1634,7 +1634,7 @@ packages: description: name: video_player_platform_interface sha256: be72301bf2c0150ab35a8c34d66e5a99de525f6de1e8d27c0672b836fe48f73a - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "6.2.1" video_player_web: @@ -1642,7 +1642,7 @@ packages: description: name: video_player_web sha256: ab7a462b07d9ca80bed579e30fb3bce372468f1b78642e0911b10600f2c5cb5b - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.2" vm_service: @@ -1650,7 +1650,7 @@ packages: description: name: vm_service sha256: c538be99af830f478718b51630ec1b6bee5e74e52c8a802d328d9e71d35d2583 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "11.10.0" wakelock_plus: @@ -1658,7 +1658,7 @@ packages: description: name: wakelock_plus sha256: f268ca2116db22e57577fb99d52515a24bdc1d570f12ac18bb762361d43b043d - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.1.4" wakelock_plus_platform_interface: @@ -1666,7 +1666,7 @@ packages: description: name: wakelock_plus_platform_interface sha256: "40fabed5da06caff0796dc638e1f07ee395fb18801fbff3255a2372db2d80385" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.1.0" watcher: @@ -1674,7 +1674,7 @@ packages: description: name: watcher sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.1.0" web: @@ -1682,7 +1682,7 @@ packages: description: name: web sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.3.0" web_socket_channel: @@ -1690,7 +1690,7 @@ packages: description: name: web_socket_channel sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.4.0" webdriver: @@ -1698,7 +1698,7 @@ packages: description: name: webdriver sha256: "3c923e918918feeb90c4c9fdf1fe39220fa4c0e8e2c0fffaded174498ef86c49" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.0.2" webkit_inspection_protocol: @@ -1706,7 +1706,7 @@ packages: description: name: webkit_inspection_protocol sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.2.1" webview_flutter: @@ -1714,7 +1714,7 @@ packages: description: name: webview_flutter sha256: "392c1d83b70fe2495de3ea2c84531268d5b8de2de3f01086a53334d8b6030a88" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.0.4" webview_flutter_android: @@ -1722,7 +1722,7 @@ packages: description: name: webview_flutter_android sha256: "8b3b2450e98876c70bfcead876d9390573b34b9418c19e28168b74f6cb252dbd" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.10.4" webview_flutter_platform_interface: @@ -1730,7 +1730,7 @@ packages: description: name: webview_flutter_platform_interface sha256: "812165e4e34ca677bdfbfa58c01e33b27fd03ab5fa75b70832d4b7d4ca1fa8cf" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.9.5" webview_flutter_plus: @@ -1738,7 +1738,7 @@ packages: description: name: webview_flutter_plus sha256: bea8756ae096529254725def7c4a633851a785c7d49206e0817125ab02b14307 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.3.0+2" webview_flutter_wkwebview: @@ -1746,7 +1746,7 @@ packages: description: name: webview_flutter_wkwebview sha256: a5364369c758892aa487cbf59ea41d9edd10f9d9baf06a94e80f1bd1b4c7bbc0 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.9.5" win32: @@ -1754,7 +1754,7 @@ packages: description: name: win32 sha256: b0f37db61ba2f2e9b7a78a1caece0052564d1bc70668156cf3a29d676fe4e574 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "5.1.1" xdg_directories: @@ -1762,7 +1762,7 @@ packages: description: name: xdg_directories sha256: "589ada45ba9e39405c198fe34eb0f607cddb2108527e658136120892beac46d2" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.3" xml: @@ -1770,7 +1770,7 @@ packages: description: name: xml sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "6.5.0" yaml: @@ -1778,7 +1778,7 @@ packages: description: name: yaml sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.1.2" sdks: diff --git a/test/add_remove_retweet_api_test.dart b/test/add_remove_retweet_api_test.dart new file mode 100644 index 00000000..78ce1d59 --- /dev/null +++ b/test/add_remove_retweet_api_test.dart @@ -0,0 +1,75 @@ +import 'package:dio/dio.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:tweaxy/constants.dart'; +import 'package:tweaxy/services/like_tweet.dart'; +import 'package:tweaxy/services/tweets_services.dart'; + +void main() { + String tweetId = 'b94430alg723ceppltg3hq9my'; + String token = + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiaDJud2hld3NjNTk0eXJiNHB6Y2tqc2w3eVwiIiwiaWF0IjoxNzAzNjk1NjEwLCJleHAiOjE3MDYyODc2MTB9.mgE8vixCONaqkLKkzlbcCCdUE1HZkGDp7Rky7ohwbTA'; + group('ReTweet', () { + test('Re-Tweet', () async { + var response = await addRetweet(tweetId, token); + + expect(response, true); + }); + test('Re-Tweet with invalid token', () async { + var response = await addRetweet(tweetId, '-1'); + + expect(response, false); + }); + test('Re-Tweet on an already retweeted post', () async { + var response = await addRetweet(tweetId,token); + + expect(response, false); + }); + test('Delete Re-Tweet ', () async { + var response = await deleteRetweet(tweetId,token); + + expect(response, true); + }); + test('Delete Re-Tweet with invalid token ', () async { + var response = await deleteRetweet(tweetId,'-1'); + + expect(response, false); + }); + test('Delete Re-Tweet where no retweet ', () async { + var response = await deleteRetweet(tweetId,'-1'); + + expect(response, false); + }); + + }); +} + +Future addRetweet(String id, String token) async { + var dio = Dio(); + + try { + var response = await dio.post( + '${baseURL}interactions/$id/retweet', + options: Options(headers: {'Authorization': 'Bearer ${token}'}), + ); + print(response.toString()); + print('Liked'); + return true; + } catch (e) { + return false; + } +} +Future deleteRetweet(String id, String token) async { + var dio = Dio(); + + try { + var response = await dio.delete( + '${baseURL}interactions/retweet/$id', + options: Options(headers: {'Authorization': 'Bearer ${token}'}), + ); + print(response.toString()); + print('Liked'); + return true; + } catch (e) { + return false; + } +} diff --git a/test/chat_api_test.dart b/test/chat_api_test.dart new file mode 100644 index 00000000..d72e176c --- /dev/null +++ b/test/chat_api_test.dart @@ -0,0 +1,132 @@ +import 'dart:developer'; + +import 'package:chatview/chatview.dart'; +import 'package:dio/dio.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:tweaxy/models/conversation_model.dart'; +import 'package:tweaxy/services/chat_room_service.dart'; +import 'package:tweaxy/services/get_conversation_service.dart'; +import 'package:tweaxy/services/temp_user.dart'; +import 'package:socket_io_client/socket_io_client.dart' as ioo; + +void main() { + TempUser.token = + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwieDU4ZzNtajMybTUxaGt3b2Q2MHZjbXNjZlwiIiwiaWF0IjoxNzAzNjgxNDgzLCJleHAiOjE3MDYyNzM0ODN9.bZ5UKTjh0IxpS9xZSnrokp-p-35E2ml9m5OACgjEJcE'; + + TempUser.id = 'x58g3mj32m51hkwod60vcmscf'; + GetConversationsService getConvService = GetConversationsService(Dio()); + ChatRoomService chatRoomService = ChatRoomService(Dio()); + ConversationModel convo = ConversationModel( + conversationID: '', + userID: '', + username: '', + name: '', + userAvatar: '', + lastMessage: null, + isBlockedByMe: false, + isBlockingMe: false, + isMutedByMe: false, + isMutingMe: false, + userFollowersNum: 0, + userFollowingsNum: 0, + unseenCount: 0, + ); + String newConvoID = ''; + ioo.Socket socket = + ioo.io('https://tweaxychat.gleeze.com/', { + 'transports': ['websocket'], // optional your need for + 'autoConnect': false, + }); + socket.auth = {"token": TempUser.token}; + socket.connect(); + + socket.onConnect((_) { + log('connect'); + }); + socket.on('event', (data) => log(data.toString())); + socket.on('fromServer', (_) => log(_.toString())); + socket.onConnect((data) { + log(data.toString()); + }); + socket.onConnecting((data) { + log(data.toString()); + }); + socket.onConnectError((data) { + log(data.toString()); + }); + socket.onConnectTimeout((data) { + log(data.toString()); + }); + socket.onError((data) { + log(data.toString()); + }); + + group('chat_test', () { + test('Test1 : get conversations', () async { + var response = await getConvService.getConversations(TempUser.token, + limit: 7, pageNumber: 0); + convo = response[0]; + expect(response, isA>()); + }); + + test("Test2: get old messages", () async { + var response = await chatRoomService.getMessages( + TempUser.token, convo.conversationID, 0); + expect(response, isA>()); + }); + + test('Test3: get messages', () async { + socket.on('message', (data) { + expect(data['text'], isA()); + }); + }); + test("Test4: send message for existing conversations", () async { + socket.emit( + 'sendMessage', + { + "id": TempUser.id, + "conversationID": convo.conversationID, + "text": "helllooo from test :)", + "media": null + }, + ); + socket.on('message', (data) { + expect(data['text'], "helllooo from test :)"); + }); + }); + test("Test5: send empty message", () async { + socket.emit( + 'sendMessage', + { + "id": TempUser.id, + "conversationID": convo.conversationID, + "text": "", + "media": null + }, + ); + socket.on('message', (data) { + expect(data, null); + }); + }); + test("Test6: Create new conversations", () async { + var response = await chatRoomService.firstConversation( + TempUser.token, "eman_ibrahim"); + newConvoID = response; + expect(response, isA); + }); + test("Test7: send message for new conversations", () async { + socket.emit( + 'sendMessage', + { + "id": TempUser.id, + "conversationID": newConvoID, + "text": "helllooo from test :)", + "media": null + }, + ); + socket.on('message', (data) { + expect(data['text'], "helllooo from test :)"); + }); + }); + }); +} diff --git a/test/delete_tweet_test.dart b/test/delete_tweet_test.dart new file mode 100644 index 00000000..b4313cb8 --- /dev/null +++ b/test/delete_tweet_test.dart @@ -0,0 +1,32 @@ +import 'package:dio/dio.dart'; +import 'package:test/expect.dart'; +import 'package:test/scaffolding.dart'; +import 'package:tweaxy/constants.dart'; +import 'package:tweaxy/helpers/api.dart'; +import 'package:tweaxy/models/tweet.dart'; +import 'package:tweaxy/services/sign_in.dart'; +import 'package:tweaxy/services/tweets_services.dart'; +import 'package:tweaxy/utilities/tweets_utilities.dart'; + +void main() { + String tweetid = 'xz5jzcgv7icfnmzqoevkqnob0'; + String token = + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiaDJud2hld3NjNTk0eXJiNHB6Y2tqc2w3eVwiIiwiaWF0IjoxNzAzNjkzNzYzLCJleHAiOjE3MDYyODU3NjN9.9IeCNdaMQu3zf8qDU_MLDK7e0cUBgayQfuVJApW5mPQ"; + group('Test Delete Tweets ', () { + group('Test Delete Tweets Api', () { + test('Test1: Delete Tweet for valid tweetid and valid token', () async { + dynamic res = await Api.delete( + url: '${baseURL}interactions/$tweetid', token: token); + + expect( + await Api.delete( + url: '${baseURL}interactions/$tweetid', token: token), + "success"); + }); + }); + }); +} + +void runTests() async { + await Future.delayed(const Duration(seconds: 30)); +} diff --git a/test/get_followers.dart b/test/get_followers.dart index 26a2d17d..2d6cf50d 100644 --- a/test/get_followers.dart +++ b/test/get_followers.dart @@ -1,8 +1,3 @@ -import 'dart:developer'; -import 'dart:ui' as ui; -import 'dart:io' as io; -import 'dart:math'; -import 'package:dio/dio.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:tweaxy/models/followers_model.dart'; import 'package:tweaxy/services/FollowersAndFollwing.dart'; diff --git a/test/get_following.dart b/test/get_following.dart index 984dbdaf..926c4fb1 100644 --- a/test/get_following.dart +++ b/test/get_following.dart @@ -1,8 +1,3 @@ -import 'dart:developer'; -import 'dart:ui' as ui; -import 'dart:io' as io; -import 'dart:math'; -import 'package:dio/dio.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:tweaxy/models/followers_model.dart'; import 'package:tweaxy/services/FollowersAndFollwing.dart'; diff --git a/test/get_likers.dart b/test/get_likers.dart index da98af7a..fa3b3b9f 100644 --- a/test/get_likers.dart +++ b/test/get_likers.dart @@ -1,11 +1,5 @@ -import 'dart:developer'; -import 'dart:ui' as ui; -import 'dart:io' as io; -import 'dart:math'; -import 'package:dio/dio.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:tweaxy/models/followers_model.dart'; -import 'package:tweaxy/services/FollowersAndFollwing.dart'; import 'package:tweaxy/services/get_likers.dart'; void main() { diff --git a/test/get_likes_in_profile_api_test.dart b/test/get_likes_in_profile_api_test.dart index 22a992d9..68a7b310 100644 --- a/test/get_likes_in_profile_api_test.dart +++ b/test/get_likes_in_profile_api_test.dart @@ -1,21 +1,36 @@ -// import 'package:dio/dio.dart'; -// import 'package:flutter_test/flutter_test.dart'; -// import 'package:tweaxy/services/get_likers_in_profile.dart'; +import 'package:dio/dio.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:tweaxy/constants.dart'; +import 'package:tweaxy/helpers/api.dart'; -// void main() async { -// GetLikersInProfile service = GetLikersInProfile(Dio()); -// group('GetUserById testing', () { -// test('Test1 : Get liked Tweet Successfuly', () async { -// expect(await service.likersList(pageNumber: 10), []); -// }); -// test('Test2 : Wrong ID ', () async { -// expect(await service.likersList(pageNumber: 0), []); -// }); -// test('Test3 : Send Wrong Paramenters ', () async { -// expect(await service.likersList(pageNumber: -1), -// []); -// }); -// }); -// } +void main() async { +Future getLikes(String id, int page, String? token) async { + return await await Api.getwithToken( + url: '${baseURL}users/tweets/liked/$id?limit=4&offset=$page', + token: token); + +} + group('GetUserById testing', () { + test('Test1 : Get liked Tweet Successfuly', () async { + expect(await getLikes("", 0,null), "no token provided"); + }); + test('Test2 : Wrong ID ', () async { + expect( + await getLikes("2155", 0, + "token"), + "token not valid"); + }); + + test('Test3 : not send user id ', () async { + expect(await getLikes("", 0,"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiYTQ0bzlsem9qbGtybnZscmxhZDQ4dW1jN1wiIiwiaWF0IjoxNzAzNzExMTY0LCJleHAiOjE3MDYzMDMxNjR9.GoHIWsZ8mOeCWxyP_nszBXDxfY-BhVcLHzCyZjwKqeQ"), + "no user found "); + }); + + test('Test4 : sucess get ', () async { + expect(await getLikes("a44o9lzojlkrnvlrlad48umc7", 0,"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiYTQ0bzlsem9qbGtybnZscmxhZDQ4dW1jN1wiIiwiaWF0IjoxNzAzNzExNTIwLCJleHAiOjE3MDYzMDM1MjB9.IwwR_Da6_YgIcxE04QR6pQph55G6yGP8uWwD7zK7oYM"), + isA>()); + }); + }); +} diff --git a/test/get_messages_test.dart b/test/get_messages_test.dart new file mode 100644 index 00000000..fa826788 --- /dev/null +++ b/test/get_messages_test.dart @@ -0,0 +1,31 @@ +import 'package:test/expect.dart'; +import 'package:test/scaffolding.dart'; +import 'package:tweaxy/constants.dart'; +import 'package:tweaxy/helpers/api.dart'; + +void main() { +dynamic getMessages(String id, String token) async { + + return await Api.getwithToken( + url: '${baseURL}conversations/$id?limit=10&offset=0', token: "token"); + } + + group('Test get messages api', () { + test('Test1: get messages ', () async { + dynamic res= await getMessages("", ""); + expect( + res, + "token not valid"); + }); + test('Test2: get messages ', () async { + expect( + await getMessages("1235mmm45", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiYTQ0bzlsem9qbGtybnZscmxhZDQ4dW1jN1wiIiwiaWF0IjoxNzAzNzEwMjQ1LCJleHAiOjE3MDYzMDIyNDV9.Noydn7vKZgYFyOXhiFtylQiIXLWWAbi2RVyRWzrVSKg"), + "token not valid"); + }); + test('Test2: get messages ', () async { + expect( + await getMessages("","bnZscmxhZDQ4dW1jN1wiIiwiaWF0IjoxNzAzNzEwMjQ1LCJleHAiOjE3MDYzMDIyNDV9.Noydn7vKZgYFyOXhiFtylQiIXLWWAbi2RVyRWzrVSKg"), + "token not valid"); + }); + }); +} diff --git a/test/get_replies_test.dart b/test/get_replies_test.dart new file mode 100644 index 00000000..39a6399d --- /dev/null +++ b/test/get_replies_test.dart @@ -0,0 +1,51 @@ +import 'package:dio/dio.dart'; +import 'package:test/expect.dart'; +import 'package:test/scaffolding.dart'; +import 'package:tweaxy/constants.dart'; +import 'package:tweaxy/helpers/api.dart'; +import 'package:tweaxy/models/tweet.dart'; +import 'package:tweaxy/services/sign_in.dart'; +import 'package:tweaxy/services/tweets_services.dart'; +import 'package:tweaxy/utilities/tweets_utilities.dart'; + +void main() { + String tweetId = 'b94430alg723ceppltg3hq9my'; + String token = + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiaDJud2hld3NjNTk0eXJiNHB6Y2tqc2w3eVwiIiwiaWF0IjoxNzAzNjk0Nzk4LCJleHAiOjE3MDYyODY3OTh9.cizBQ_4z1mRO5-qv335hjpJHRMRohBBSm_c2DrSKpyU'; + group('Test Get Replies Api', () { + group('Test Get Replies Api', () { + test('Test1: Get Replies for invalid token', () async { + expect( + await Api.getwithToken( + url: '${baseURL}interactions/$tweetId/replies?limit=5&offset=3', + token: '-1'), + "token not valid"); + }); + + test('Test2: Get Replies for valid token and userid', () async { + expect(await postsReplies(tweetId, token), isA>()); + }); + test('Test3: Get Replies for invalid tweetid', () async { + expect( await Api.getwithToken( + url: '${baseURL}interactions/-1/replies?limit=5&offset=3', + token: token), + "no interaction found "); + }); + }); + }); +} + +Future> postsReplies(String tweetId, String token) async { + Response res = await Api.getwithToken( + url: '${baseURL}interactions/$tweetId/replies?limit=5&offset=3', + token: token); + + List> m = await mapToList(res,isforreply: true); + + List t = initializeTweets(m); + return t; +} + +void runTests() async { + await Future.delayed(const Duration(seconds: 30)); +} diff --git a/test/get_tweets_home_test.dart b/test/get_tweets_home_test.dart index 7c861a10..114fc2d6 100644 --- a/test/get_tweets_home_test.dart +++ b/test/get_tweets_home_test.dart @@ -1,24 +1,44 @@ -import 'package:dio/dio.dart'; import 'package:test/expect.dart'; import 'package:test/scaffolding.dart'; import 'package:tweaxy/constants.dart'; import 'package:tweaxy/helpers/api.dart'; +import 'package:tweaxy/models/tweet.dart'; import 'package:tweaxy/services/sign_in.dart'; import 'package:tweaxy/services/tweets_services.dart'; +import 'package:tweaxy/utilities/tweets_utilities.dart'; +import 'package:dio/dio.dart'; -void main() { - String baseUrl = '${baseURL}'; +void main() { + String userid = "eissqonj1eb4g2fgrbr3idsam"; + String token = + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiZWlzc3FvbmoxZWI0ZzJmZ3JicjNpZHNhbVwiIiwiaWF0IjoxNzAzNjg3NzgxLCJleHAiOjE3MDYyNzk3ODF9.1n_frZ40vH0NxBwBWdAxcM26z-gNdN4XROoR9gkmJt0'; group('Test Get Tweets Home Api', () { - test('Test1: Get Tweets Home for invalid token', () async { - expect( - await Api.getwithToken( - url: '${baseURL}home?/limit=5&offset=2', token: '5'), - "token not valid"); + group('Test Get Tweets Home Api', () { + test('Test1: Get Tweets Profile for invalid token', () async { + expect( + await Api.getwithToken( + url: '${baseURL}home?/limit=10&offset=3', token: '-1'), + "token not valid"); + }); + + test('Test2: Get Tweets Home for valid token and userid', () async { + expect(await postsInHome('0', token), isA>()); + }); }); }); } +Future> postsInHome(String offset, String token) async { + Response res = await Api.getwithToken( + url: '${baseURL}home?/limit=10&offset=$offset', token: token); + + List> m = await mapToList(res); + + List t = initializeTweets(m); + return t; +} + void runTests() async { await Future.delayed(const Duration(seconds: 30)); } diff --git a/test/get_tweets_profile_test.dart b/test/get_tweets_profile_test.dart index 28f35d34..009ea5e3 100644 --- a/test/get_tweets_profile_test.dart +++ b/test/get_tweets_profile_test.dart @@ -3,30 +3,49 @@ import 'package:test/expect.dart'; import 'package:test/scaffolding.dart'; import 'package:tweaxy/constants.dart'; import 'package:tweaxy/helpers/api.dart'; -import 'package:tweaxy/services/sign_in.dart'; +import 'package:tweaxy/models/tweet.dart'; import 'package:tweaxy/services/tweets_services.dart'; +import 'package:tweaxy/utilities/tweets_utilities.dart'; void main() { - String baseUrl = 'https://tweaxybackend.mywire.org/api/v1'; - String userid = "gz8kvi9ki9eaud3b1m46woduh"; + String userid = "eissqonj1eb4g2fgrbr3idsam"; + String token = + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiZWlzc3FvbmoxZWI0ZzJmZ3JicjNpZHNhbVwiIiwiaWF0IjoxNzAzNjg3NzgxLCJleHAiOjE3MDYyNzk3ODF9.1n_frZ40vH0NxBwBWdAxcM26z-gNdN4XROoR9gkmJt0'; + print(baseURL.toString()); group('Test Get Tweets Profile Api', () { test('Test1: Get Tweets Profile for invalid user id', () async { expect( await Api.getwithToken( - url: '${baseURL}users/-1/tweets?limit=5&offset=2', token: '5'), + url: '${baseURL}users/tweets/-1?limit=5&offset=3', token: token), "no user found "); }); - // test('Test2: Get Tweets Profile for valid user id and invalid token', - // () async { - // expect( - // await Api.getwithToken( - // url: '$baseUrl/users/$userid/tweets?limit=5&offset=2', - // token: '---0'), - // "no user found"); - // }); + test('Test2: Get Tweets Profile for invalid token', () async { + expect( + await Api.getwithToken( + url: '${baseURL}users/tweets/-1?limit=5&offset=3', token: '-1'), + "token not valid"); + }); + + test('Test3: Get Tweets Profile for valid token and userid', () async { + expect( + await postsInProfile(userid, '0', token), isA>()); + }); }); } +Future> postsInProfile( + String id, String offset, String token) async { + Response res = await Api.getwithToken( + url: '${baseURL}users/tweets/$id?limit=5&offset=$offset', token: token); + + // Response response = res; + + // print('rrrrr' + res.toString()); + List> m = await mapToList(res); + List t = initializeTweets(m); + return t; +} + void runTests() async { await Future.delayed(const Duration(seconds: 30)); } diff --git a/test/get_tweets_trend_test.dart b/test/get_tweets_trend_test.dart new file mode 100644 index 00000000..32295498 --- /dev/null +++ b/test/get_tweets_trend_test.dart @@ -0,0 +1,44 @@ +import 'package:dio/dio.dart'; +import 'package:test/expect.dart'; +import 'package:test/scaffolding.dart'; +import 'package:tweaxy/constants.dart'; +import 'package:tweaxy/helpers/api.dart'; +import 'package:tweaxy/models/tweet.dart'; +import 'package:tweaxy/services/sign_in.dart'; +import 'package:tweaxy/services/tweets_services.dart'; +import 'package:tweaxy/utilities/tweets_utilities.dart'; + +void main() { + String userid = "eissqonj1eb4g2fgrbr3idsam"; + String token = + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiZWlzc3FvbmoxZWI0ZzJmZ3JicjNpZHNhbVwiIiwiaWF0IjoxNzAzNjg3NzgxLCJleHAiOjE3MDYyNzk3ODF9.1n_frZ40vH0NxBwBWdAxcM26z-gNdN4XROoR9gkmJt0'; + group('Test Get Tweets Trend Api', () { + group('Test Get Tweets Trend Api', () { + test('Test1: Get Tweets Trend for invalid token', () async { + expect( + await Api.getwithToken( + url: '${baseURL}trends/hello?limit=5&offset=3', token: '-1'), + "token not valid"); + }); + + test('Test2: Get Tweets Trend for valid token and userid', () async { + expect(await postsInTrends('0', token), isA>()); + }); + + }); + }); +} + +Future> postsInTrends(String offset, String token) async { + Response res = await Api.getwithToken( + url: '${baseURL}trends/adimpleo?limit=5&offset=$offset', token: token); + + List> m = await mapToList(res); + + List t = initializeTweets(m); + return t; +} + +void runTests() async { + await Future.delayed(const Duration(seconds: 30)); +} diff --git a/test/login_password.dart b/test/login_password.dart index 04d440cb..7b5f02d8 100644 --- a/test/login_password.dart +++ b/test/login_password.dart @@ -1,5 +1,3 @@ -import 'dart:io'; -import 'dart:math'; import 'package:dio/dio.dart'; import 'package:test/expect.dart'; diff --git a/test/login_username.dart b/test/login_username.dart index 3d45bfd8..7011cd45 100644 --- a/test/login_username.dart +++ b/test/login_username.dart @@ -1,5 +1,3 @@ -import 'dart:io'; -import 'dart:math'; import 'package:dio/dio.dart'; import 'package:test/expect.dart'; diff --git a/test/notification_disable_test.dart b/test/notification_disable_test.dart new file mode 100644 index 00000000..edad11c1 --- /dev/null +++ b/test/notification_disable_test.dart @@ -0,0 +1,21 @@ +import 'package:dio/dio.dart'; +import 'package:test/expect.dart'; +import 'package:test/scaffolding.dart'; +import 'package:tweaxy/constants.dart'; +import 'package:tweaxy/helpers/api.dart'; + +void main() { + group('Test notification disable', () { + + test('Test1: sucess enable ', () async { + expect( + await Api.delete( + url: '${baseURL}notification/deviceTokenAndorid', + token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiY2xvdWRlemdnMDAwMDM1Nm1tbW5ybzh6ZVwiIiwiaWF0IjoxNzAzNzA3MzYzLCJleHAiOjE3MDYyOTkzNjN9.iT3hMhHXZKtui8LxUtXwZ6sbEaKDieqrkJ09AnQr_x4", + body: {"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiY2xvdWRlemdnMDAwMDM1Nm1tbW5ybzh6ZVwiIiwiaWF0IjoxNzAzNzA3MzYzLCJleHAiOjE3MDYyOTkzNjN9.iT3hMhHXZKtui8LxUtXwZ6sbEaKDieqrkJ09AnQr_x4"}, + ), + isA>()); + }); + + }); +} diff --git a/test/notification_enable_test.dart b/test/notification_enable_test.dart new file mode 100644 index 00000000..36656b11 --- /dev/null +++ b/test/notification_enable_test.dart @@ -0,0 +1,55 @@ +import 'package:dio/dio.dart'; +import 'package:test/expect.dart'; +import 'package:test/scaffolding.dart'; +import 'package:tweaxy/constants.dart'; +import 'package:tweaxy/helpers/api.dart'; + +void main() { + group('Test notification enable', () { + test('Test1: token not provided', () async { + expect( + await Api.post( + url: '${baseURL}notification/deviceTokenAndorid', + token: "", + body: {"": "deviceToken"}, + ), + "token is required"); + }); + test('Test2: wrong token is given ', () async { + expect( + await Api.post( + url: '${baseURL}notification/deviceTokenAndorid', + token: "wrong token", + body: {"token": "deviceToken"}, + ), + "token not valid"); + }); + test('Test3: wrong token is given ', () async { + expect( + await Api.post( + url: '${baseURL}notification/deviceTokenAndorid', + token: "wrong token", + body: {"token": "deviceToken"}, + ), + "token not valid"); + }); + test('Test4: sucess enable ', () async { + expect( + await Api.post( + url: '${baseURL}notification/deviceTokenAndorid', + token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiY2xvdWRlemdnMDAwMDM1Nm1tbW5ybzh6ZVwiIiwiaWF0IjoxNzAzNzA3MzYzLCJleHAiOjE3MDYyOTkzNjN9.iT3hMhHXZKtui8LxUtXwZ6sbEaKDieqrkJ09AnQr_x4", + body: {"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiY2xvdWRlemdnMDAwMDM1Nm1tbW5ybzh6ZVwiIiwiaWF0IjoxNzAzNzA3MzYzLCJleHAiOjE3MDYyOTkzNjN9.iT3hMhHXZKtui8LxUtXwZ6sbEaKDieqrkJ09AnQr_x4"}, + ), + isA>()); + }); + test('Test4: token already exists ', () async { + expect( + await Api.post( + url: '${baseURL}notification/deviceTokenAndorid', + token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiY2xvdWRlemdnMDAwMDM1Nm1tbW5ybzh6ZVwiIiwiaWF0IjoxNzAzNzA3MzYzLCJleHAiOjE3MDYyOTkzNjN9.iT3hMhHXZKtui8LxUtXwZ6sbEaKDieqrkJ09AnQr_x4", + body: {"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiY2xvdWRlemdnMDAwMDM1Nm1tbW5ybzh6ZVwiIiwiaWF0IjoxNzAzNzA3MzYzLCJleHAiOjE3MDYyOTkzNjN9.iT3hMhHXZKtui8LxUtXwZ6sbEaKDieqrkJ09AnQr_x4"}, + ), + "this token already exists"); + }); + }); +} diff --git a/test/notification_status_test.dart b/test/notification_status_test.dart new file mode 100644 index 00000000..22c5408a --- /dev/null +++ b/test/notification_status_test.dart @@ -0,0 +1,34 @@ +import 'package:dio/dio.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:tweaxy/helpers/api.dart'; + +void main() { + Future enableNotification(String token) async { + dynamic response; + + response = await Api.post( + url: 'https://tweaxybackend.mywire.org/api/v1/notification/status', + token: token, + body: {"token": token, "type": "android"}, + ); + + return response; + } + + group('Test Notification Settings enable Api', () { + test('Test 1: enable notification successfully', () async { + dynamic result = await enableNotification("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiY2xvdWRlemdnMDAwMDM1Nm1tbW5ybzh6ZVwiIiwiaWF0IjoxNzAzNzA3MzYzLCJleHAiOjE3MDYyOTkzNjN9.iT3hMhHXZKtui8LxUtXwZ6sbEaKDieqrkJ09AnQr_x4"); + expect(result, isA>()); + }); + + test('Test 2: token is invalid', () async { + dynamic result = await enableNotification( "eyJhbGciOiJIUzI1Ni"); + expect(result, "token not valid"); + }); + + test('Test 3: token is required', () async { + dynamic result = await enableNotification(""); // Pass null or any invalid token + expect(result, "token is required"); + }); + }); +} diff --git a/test/notification_test.dart b/test/notification_test.dart new file mode 100644 index 00000000..2fab33dd --- /dev/null +++ b/test/notification_test.dart @@ -0,0 +1,37 @@ +import 'dart:developer'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:tweaxy/helpers/api.dart'; + + + + +void main() { + Future enableNatification(String token) async { + dynamic response; + + response = await Api.post( + url: 'https://tweaxybackend.mywire.org/api/v1/notification/status', + token: token, + body: {"token": token, "type": "android"}, + ); + + return response; + +} + group('Test Notification Settings enable Api', () { + test('Test1:enable notification successfully', () async { + dynamic result = await enableNatification("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlwiY2xxbnF4ZnZxMDBibzdzejZqNGwzaHFveFwiIiwiaWF0IjoxNzAzNjkwNzc0LCJleHAiOjE3MDYyODI3NzR9.j4vR2DVH5rZ02KnQ9rLfB_rH5f4LXf1lau1pU3xy6gU"); + expect(result, "success"); + }); + log("\n"); + test('Test 2: token is invalid', () async { + dynamic result = await enableNatification(""); + expect(result, "user not authorized."); + }); + test('Test 2: token is required', () async { + dynamic result = await enableNatification(""); + expect(result, "token is required"); + }); + }); +} \ No newline at end of file diff --git a/test/reset_password_api_test.dart b/test/reset_password_api_test.dart index c612cde9..728bf7b9 100644 --- a/test/reset_password_api_test.dart +++ b/test/reset_password_api_test.dart @@ -27,10 +27,10 @@ void main() { test( 'Test4: Reset Password for Existing email but with valid password and wrong token test', () async { - SignInServices.setEmail(email: "mennaahmed0701@gmail.com"); + SignInServices.setEmail(email: "Derek_Baumbach"); SignInServices.setToken(token: 'hhh12345'); expect(await SignInServices.resetPassword('Mm12345!'), - "Reset Code is invalid"); + "User does not have reset token"); }); }); } diff --git a/test/suggestions_search.dart b/test/suggestions_search.dart index a831aff3..44791fc9 100644 --- a/test/suggestions_search.dart +++ b/test/suggestions_search.dart @@ -2,7 +2,6 @@ import 'package:dio/dio.dart'; import 'package:test/expect.dart'; import 'package:test/scaffolding.dart'; -import 'package:tweaxy/services/sign_in.dart'; import 'package:tweaxy/services/suggestions_search.dart'; void main() { diff --git a/test/update_password_api_test.dart b/test/update_password_api_test.dart index da110eb5..74f5bc98 100644 --- a/test/update_password_api_test.dart +++ b/test/update_password_api_test.dart @@ -4,10 +4,12 @@ import 'package:tweaxy/services/update_password_service.dart'; void main() async { UpdatePasswordService service = UpdatePasswordService(Dio()); + String token = ''; - group('GetUserById testing', () { + group('Update Password testing', () { test('Test1 : Update password Successfuly', () async { final response = await service.updatePassword( + token, oldPassword: '12345678tT@', newPassword: '12345678yY@', confirmPassword: '12345678yY@', @@ -18,6 +20,7 @@ void main() async { () async { expect( await service.updatePassword( + token, oldPassword: '12345678yY@', newPassword: '12345678tT@', confirmPassword: '12345677tT@'), @@ -26,7 +29,9 @@ void main() async { test('Test3: Update password with invalid new password', () async { expect( + await service.updatePassword( + token, oldPassword: '12345678yY@', newPassword: '12345678tT', confirmPassword: '12345677tT'), diff --git a/test/update_username.dart b/test/update_username.dart new file mode 100644 index 00000000..36ee9947 --- /dev/null +++ b/test/update_username.dart @@ -0,0 +1,24 @@ +import 'package:dio/dio.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:tweaxy/services/update_username_service.dart'; + +void main() async { + UpdateUsernameService service = UpdateUsernameService(Dio()); + String token = ''; + + group('Update Username testing', () { + test('Test1 : Update username Successfuly', () async { + final response = await service.updateUsername(token, 'Yarraa'); + expect(response, null); + }); + test('Test2 : Update username with invalid length username', () async { + expect(await service.updateUsername(token, 'Ya'), + 'username must be at least 4 characters'); + }); + + test('Test3: Update username with invalid username', () async { + expect(await service.updateUsername(token, 'Yarraa'), + 'username already exists.'); + }); + }); +}