Skip to content

Commit

Permalink
feat: new post context menu #322
Browse files Browse the repository at this point in the history
  • Loading branch information
lucien144 committed Dec 9, 2022
1 parent dfa49e1 commit fc47e2d
Show file tree
Hide file tree
Showing 22 changed files with 678 additions and 438 deletions.
10 changes: 5 additions & 5 deletions ios/Podfile.lock
Expand Up @@ -138,7 +138,7 @@ PODS:
- Flutter
- FlutterMacOS
- Sentry (~> 7.23.0)
- share (0.0.1):
- share_plus (0.0.1):
- Flutter
- shared_preferences_ios (0.0.1):
- Flutter
Expand Down Expand Up @@ -169,7 +169,7 @@ DEPENDENCIES:
- path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- sentry_flutter (from `.symlinks/plugins/sentry_flutter/ios`)
- share (from `.symlinks/plugins/share/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
Expand Down Expand Up @@ -221,8 +221,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/permission_handler_apple/ios"
sentry_flutter:
:path: ".symlinks/plugins/sentry_flutter/ios"
share:
:path: ".symlinks/plugins/share/ios"
share_plus:
:path: ".symlinks/plugins/share_plus/ios"
shared_preferences_ios:
:path: ".symlinks/plugins/shared_preferences_ios/ios"
sqflite:
Expand Down Expand Up @@ -263,7 +263,7 @@ SPEC CHECKSUMS:
PromisesObjC: ab77feca74fa2823e7af4249b8326368e61014cb
Sentry: a0d4563fa4ddacba31fdcc35daaa8573d87224d6
sentry_flutter: 8bde7d0e57a721727fe573f13bb292c497b5a249
share: 0b2c3e82132f5888bccca3351c504d0003b3b410
share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68
shared_preferences_ios: 548a61f8053b9b8a49ac19c1ffbc8b92c50d68ad
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
Expand Down
4 changes: 2 additions & 2 deletions ios/Runner.xcodeproj/project.pbxproj
Expand Up @@ -274,7 +274,7 @@
"${BUILT_PRODUCTS_DIR}/package_info_plus/package_info_plus.framework",
"${BUILT_PRODUCTS_DIR}/path_provider_ios/path_provider_ios.framework",
"${BUILT_PRODUCTS_DIR}/sentry_flutter/sentry_flutter.framework",
"${BUILT_PRODUCTS_DIR}/share/share.framework",
"${BUILT_PRODUCTS_DIR}/share_plus/share_plus.framework",
"${BUILT_PRODUCTS_DIR}/shared_preferences_ios/shared_preferences_ios.framework",
"${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework",
"${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework",
Expand Down Expand Up @@ -303,7 +303,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/package_info_plus.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_ios.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sentry_flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/share.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/share_plus.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences_ios.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework",
Expand Down
427 changes: 338 additions & 89 deletions lib/components/actionSheets/PostActionSheet.dart

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions lib/components/mail_list_item.dart
Expand Up @@ -14,6 +14,7 @@ import 'package:fyx/theme/IconReply.dart';
import 'package:fyx/theme/IconUnread.dart';
import 'package:fyx/theme/skin/Skin.dart';
import 'package:fyx/theme/skin/SkinColors.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';

class MailListItem extends StatefulWidget {
final Mail mail;
Expand Down Expand Up @@ -49,13 +50,11 @@ class _MailListItemState extends State<MailListItem> {
),
GestureDetector(
child: Icon(Icons.more_vert, color: colors.text.withOpacity(0.38)),
onTap: () => showCupertinoModalPopup(
onTap: () => showCupertinoModalBottomSheet(
context: context,
builder: (BuildContext context) => PostActionSheet(
builder: (BuildContext context) => PostContextMenu<Mail>(
parentContext: context,
user: widget.mail.participant,
postId: widget.mail.id,
shareData: ShareData(subject: '@${widget.mail.participant}', body: widget.mail.content, link: widget.mail.link),
item: widget.mail,
flagPostCallback: (mailId) => MainRepository().settings.blockMail(mailId),
)),
),
Expand Down
222 changes: 67 additions & 155 deletions lib/components/post/post_list_item.dart

Large diffs are not rendered by default.

206 changes: 101 additions & 105 deletions lib/components/post/post_rating.dart
Expand Up @@ -2,13 +2,14 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fyx/components/feedback_indicator.dart';
import 'package:fyx/components/post/rating_value.dart';
import 'package:fyx/components/text_icon.dart';
import 'package:fyx/controllers/ApiController.dart';
import 'package:fyx/model/Post.dart';
import 'package:fyx/model/notifications/LoadRatingsNotification.dart';
import 'package:fyx/theme/L.dart';
import 'package:fyx/theme/T.dart';
import 'package:fyx/theme/skin/Skin.dart';
import 'package:fyx/theme/skin/SkinColors.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';

class PostRating extends StatefulWidget {
final Post post;
Expand Down Expand Up @@ -42,118 +43,113 @@ class _PostRatingState extends State<PostRating> {
Widget build(BuildContext context) {
SkinColors colors = Skin.of(context).theme.colors;

return FeedbackIndicator(
isLoading: _givingRating,
child: Row(
children: <Widget>[
if (_post!.canBeRated)
GestureDetector(
child: Icon(
Icons.thumb_up,
color: _post!.myRating == 'positive' ? colors.success : colors.text.withOpacity(0.38),
return Expanded(
child: FeedbackIndicator(
isLoading: _givingRating,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
if (_post!.rating != null)
Opacity(
opacity: _givingRating ? 0 : 1,
child: GestureDetector(
child: RatingValue(_post!.rating!),
),
),
onTap: _givingRating
? null
: () {
setState(() => _givingRating = true);
ApiController().giveRating(_post!.idKlub, _post!.id, remove: _post!.myRating != 'none').then((response) {
setState(() {
_post!.rating = response.currentRating;
_post!.myRating = response.myRating;
});
if (widget.onRatingChange != null) {
widget.onRatingChange!(_post);
}
}).catchError((error) {
print(error);
T.error(L.RATING_ERROR, bg: colors.danger);
}).whenComplete(() => setState(() => _givingRating = false));
},
),
if (_post!.canBeRated)
SizedBox(
width: 12,
),
if (_post!.rating != null)
Opacity(
opacity: _givingRating ? 0 : 1,
child: GestureDetector(
child: RatingValue(_post!.rating!),
onTap: () => LoadRatingsNotification().dispatch(context),
),
),
if (_post!.rating != null)
SizedBox(
width: 12,
),
if (_post!.canBeRated)
GestureDetector(
child: Icon(
Icons.thumb_down,
color: ['negative', 'negative_visible'].contains(_post!.myRating) ? colors.danger : colors.text.withOpacity(0.38),
),
onTap: _givingRating
? null
: () {
setState(() => _givingRating = true);
ApiController().giveRating(_post!.idKlub, _post!.id, positive: false, remove: _post!.myRating != 'none').then((response) {
if (response.needsConfirmation) {
showCupertinoDialog(
context: context,
builder: (BuildContext context) => new CupertinoAlertDialog(
title: new Text(L.GENERAL_WARNING),
content: new Text(L.RATING_CONFIRMATION),
actions: [
CupertinoDialogAction(
child: new Text(L.GENERAL_CANCEL),
onPressed: () {
setState(() => _givingRating = false);
Navigator.of(context, rootNavigator: true).pop();
},
),
CupertinoDialogAction(
isDefaultAction: true,
isDestructiveAction: true,
child: new Text('Hodnotit'),
onPressed: () {
ApiController()
.giveRating(_post!.idKlub, _post!.id, positive: false, confirm: true, remove: _post!.myRating != 'none')
.then((response) {
setState(() {
_post!.rating = response.currentRating;
_post!.myRating = response.myRating;
});
if (widget.onRatingChange != null) {
widget.onRatingChange!(_post);
}
}).catchError((error) {
print(error);
T.error(L.RATING_ERROR, bg: colors.danger);
}).whenComplete(() {
setState(() => _givingRating = false);
Navigator.of(context, rootNavigator: true).pop();
});
})
],
),
);
} else {
if (_post!.canBeRated)
GestureDetector(
child: TextIcon('Paleček',
icon: MdiIcons.thumbUp,
iconColor: _post!.myRating == 'positive' ? colors.success : colors.text.withOpacity(0.38),
),
onTap: _givingRating
? null
: () {
setState(() => _givingRating = true);
ApiController().giveRating(_post!.idKlub, _post!.id, remove: _post!.myRating != 'none').then((response) {
setState(() {
_post!.rating = response.currentRating;
_post!.myRating = response.myRating;
_givingRating = false;
});
if (widget.onRatingChange != null) {
widget.onRatingChange!(_post);
}
}
}).catchError((error) {
setState(() => _givingRating = false);
T.error(L.RATING_ERROR, bg: colors.danger);
});
},
),
],
}).catchError((error) {
print(error);
T.error(L.RATING_ERROR, bg: colors.danger);
}).whenComplete(() => setState(() => _givingRating = false));
},
),
if (_post!.canBeRated)
GestureDetector(
child: TextIcon('Mínusko',
icon: MdiIcons.thumbDown,
iconColor: ['negative', 'negative_visible'].contains(_post!.myRating) ? colors.danger : colors.text.withOpacity(0.38),
),
onTap: _givingRating
? null
: () {
setState(() => _givingRating = true);
ApiController().giveRating(_post!.idKlub, _post!.id, positive: false, remove: _post!.myRating != 'none').then((response) {
if (response.needsConfirmation) {
showCupertinoDialog(
context: context,
builder: (BuildContext context) => new CupertinoAlertDialog(
title: new Text(L.GENERAL_WARNING),
content: new Text(L.RATING_CONFIRMATION),
actions: [
CupertinoDialogAction(
child: new Text(L.GENERAL_CANCEL),
onPressed: () {
setState(() => _givingRating = false);
Navigator.of(context, rootNavigator: true).pop();
},
),
CupertinoDialogAction(
isDefaultAction: true,
isDestructiveAction: true,
child: new Text('Hodnotit'),
onPressed: () {
ApiController()
.giveRating(_post!.idKlub, _post!.id, positive: false, confirm: true, remove: _post!.myRating != 'none')
.then((response) {
setState(() {
_post!.rating = response.currentRating;
_post!.myRating = response.myRating;
});
if (widget.onRatingChange != null) {
widget.onRatingChange!(_post);
}
}).catchError((error) {
print(error);
T.error(L.RATING_ERROR, bg: colors.danger);
}).whenComplete(() {
setState(() => _givingRating = false);
Navigator.of(context, rootNavigator: true).pop();
});
})
],
),
);
} else {
setState(() {
_post!.rating = response.currentRating;
_post!.myRating = response.myRating;
_givingRating = false;
});
if (widget.onRatingChange != null) {
widget.onRatingChange!(_post);
}
}
}).catchError((error) {
setState(() => _givingRating = false);
T.error(L.RATING_ERROR, bg: colors.danger);
});
},
),
SizedBox(width: 12,)
],
),
),
);
}
Expand Down

0 comments on commit fc47e2d

Please sign in to comment.