Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -127,26 +127,26 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
url: "https://pub.dev"
source: hosted
version: "10.0.9"
version: "11.0.2"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
url: "https://pub.dev"
source: hosted
version: "3.0.9"
version: "3.0.10"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
version: "3.0.2"
lints:
dependency: transitive
description:
Expand Down Expand Up @@ -259,10 +259,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
url: "https://pub.dev"
source: hosted
version: "0.7.4"
version: "0.7.6"
typed_data:
dependency: transitive
description:
Expand Down Expand Up @@ -299,10 +299,10 @@ packages:
dependency: transitive
description:
name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
url: "https://pub.dev"
source: hosted
version: "2.1.4"
version: "2.2.0"
vm_service:
dependency: transitive
description:
Expand Down Expand Up @@ -336,5 +336,5 @@ packages:
source: hosted
version: "6.5.0"
sdks:
dart: ">=3.7.0-0 <4.0.0"
dart: ">=3.9.0 <4.0.0"
flutter: ">=3.27.0"
1 change: 1 addition & 0 deletions lib/src/presentation/di/injector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:suggest_a_feature/src/presentation/localization/localization_ext
import 'package:suggest_a_feature/src/presentation/localization/localization_options.dart';
import 'package:suggest_a_feature/src/presentation/pages/theme/suggestions_theme.dart';

// Singleton accessor pattern - private implementation is intentional
// ignore: library_private_types_in_public_api
_Injector get i => _Injector();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ class _CreateEditSuggestionBottomSheetState
previous.suggestion.status != current.suggestion.status;
}

void _listener(BuildContext context, CreateEditSuggestionState state) {
Future<void> _listener(
BuildContext context,
CreateEditSuggestionState state,
) async {
final stateManager = CreateEditSuggestionManager.of(context);
if (state.savingImageResultMessageType != SavingResultMessageType.none) {
ScaffoldMessenger.of(context).showSnackBar(
Expand All @@ -105,7 +108,7 @@ class _CreateEditSuggestionBottomSheetState
} else if (state.isSubmitted) {
widget.onClose();
} else if (state.isPhotoViewOpen) {
_openPhotoView(state, stateManager);
await _openPhotoView(state, stateManager);
}
stateManager.reset();
}
Expand Down Expand Up @@ -400,11 +403,11 @@ class _PhotoPickerItem extends StatelessWidget {
tileWidth: state.suggestion.images.length > 2
? tileWidth * 0.9
: tileWidth,
onUploadPhotos: () {
onUploadPhotos: () async {
final availableNumOfPhotos = maxPhotosForOneSuggestion -
state.suggestion.images.length;
if (availableNumOfPhotos > 0) {
stateManager.addUploadedPhotos(
await stateManager.addUploadedPhotos(
onUploadMultiplePhotos!(
availableNumOfPhotos: availableNumOfPhotos,
),
Expand Down
60 changes: 27 additions & 33 deletions lib/src/presentation/pages/suggestion/suggestion_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,7 @@ class _UserInfo extends StatelessWidget {
),
if (onShareSuggestion != null)
IconButton(
onPressed: () {
onShareSuggestion!(suggestionId);
},
onPressed: () => onShareSuggestion!(suggestionId),
icon: const Icon(Icons.share),
),
],
Expand Down Expand Up @@ -500,26 +498,24 @@ class _WrappedAttachedImage extends StatelessWidget {
Widget build(BuildContext context) {
final suggestionManager = SuggestionManager.of(context);
return GestureDetector(
onTap: () {
showDialog<void>(
useSafeArea: false,
barrierColor: Colors.black,
context: context,
useRootNavigator: false,
builder: (_) {
return PhotoView(
onDownloadClick: onSaveToGallery != null
? (path) => suggestionManager.showSavingResultMessage(
onSaveToGallery!(path),
)
: null,
initialIndex: images.indexOf(attachedImage),
photos: images,
previousNavBarColor: context.theme.colorScheme.surface,
);
},
);
},
onTap: () => showDialog<void>(
useSafeArea: false,
barrierColor: Colors.black,
context: context,
useRootNavigator: false,
builder: (_) {
return PhotoView(
onDownloadClick: onSaveToGallery != null
? (path) => suggestionManager.showSavingResultMessage(
onSaveToGallery!(path),
)
: null,
initialIndex: images.indexOf(attachedImage),
photos: images,
previousNavBarColor: context.theme.colorScheme.surface,
);
},
),
child: Container(
width: (MediaQuery.of(context).size.width - 80) / 3,
height: (MediaQuery.of(context).size.width - 80) / 3,
Expand Down Expand Up @@ -627,10 +623,9 @@ class _OpenConfirmationBottomSheet extends StatelessWidget {
return ConfirmationBottomSheet(
controller: sheetController,
question: localization.deletionQuestion,
onConfirm: () {
stateManager
..closeBottomSheet()
..deleteSuggestion();
onConfirm: () async {
stateManager.closeBottomSheet();
await stateManager.deleteSuggestion();
},
onCancel: ([_]) async {
await sheetController.collapse();
Expand All @@ -653,10 +648,9 @@ class _OpenCommentConfirmationBottomSheet extends StatelessWidget {
return ConfirmationBottomSheet(
controller: sheetController,
question: localization.deletionCommentQuestion,
onConfirm: () {
stateManager
..closeBottomSheet()
..deleteComment();
onConfirm: () async {
stateManager.closeBottomSheet();
await stateManager.deleteComment();
},
onCancel: ([_]) async {
await sheetController.collapse();
Expand Down Expand Up @@ -768,8 +762,8 @@ class _OpenCreateCommentBottomSheet extends StatelessWidget {
String text, {
required bool isAnonymous,
required bool postedByAdmin,
}) {
stateManager.createComment(
}) async {
await stateManager.createComment(
text,
onGetUserById,
isAnonymous: isAnonymous,
Expand Down
22 changes: 12 additions & 10 deletions lib/src/presentation/pages/suggestion/suggestion_state_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,27 @@ class SuggestionStateManager extends State<SuggestionManager> {
suggestion: Suggestion.empty(),
loadingComments: true,
);
_init(
suggestion: widget.suggestion,
getUserById: widget.onGetUserById,
isAdmin: i.isAdmin,
unawaited(
_init(
suggestion: widget.suggestion,
getUserById: widget.onGetUserById,
isAdmin: i.isAdmin,
),
);
}

@override
void dispose() {
_suggestionSubscription?.cancel();
unawaited(_suggestionSubscription?.cancel());
_suggestionSubscription = null;
super.dispose();
}

void _init({
Future<void> _init({
required Suggestion suggestion,
required OnGetUserById getUserById,
required bool isAdmin,
}) {
}) async {
_update(
state.newState(
suggestion: suggestion,
Expand All @@ -77,7 +79,7 @@ class SuggestionStateManager extends State<SuggestionManager> {
isAdmin,
),
);
_suggestionSubscription?.cancel();
await _suggestionSubscription?.cancel();
_suggestionSubscription =
_suggestionRepository.suggestionsStream.listen(_onNewSuggestions);
_loadComments(getUserById, suggestion.id);
Expand Down Expand Up @@ -137,7 +139,7 @@ class SuggestionStateManager extends State<SuggestionManager> {
state.suggestion,
saveComments: false,
);
} catch (e) {
} on Exception catch (e) {
log('Comments loading error', error: e);
}
_update(
Expand Down Expand Up @@ -286,7 +288,7 @@ class SuggestionStateManager extends State<SuggestionManager> {
state.suggestion,
saveComments: false,
);
} catch (e) {
} on Exception catch (e) {
log('Comment creation error', error: e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ class SuggestionsStateManager extends State<SuggestionsManager> {
sortType: widget.sortType,
loading: true,
);
_init();
unawaited(_init());
}

Future<void> _init() async {
_suggestionSubscription?.cancel();
await _suggestionSubscription?.cancel();
_suggestionSubscription = _suggestionRepository.suggestionsStream.listen(
_onNewSuggestions,
);
Expand All @@ -74,7 +74,7 @@ class SuggestionsStateManager extends State<SuggestionsManager> {
loading: state.loading,
suggestion: suggestion,
);
} catch (e) {
} on Exception catch (e) {
if (kDebugMode) {
log('Redirect to suggestion error', error: e);
}
Expand All @@ -86,7 +86,7 @@ class SuggestionsStateManager extends State<SuggestionsManager> {

@override
void dispose() {
_suggestionSubscription?.cancel();
unawaited(_suggestionSubscription?.cancel());
_suggestionSubscription = null;
super.dispose();
}
Expand Down Expand Up @@ -187,10 +187,10 @@ class SuggestionsStateManager extends State<SuggestionsManager> {
),
);

void onSortTypeChanged(SortType sortType) {
Future<void> onSortTypeChanged(SortType sortType) async {
if (sortType != state.sortType) {
_update(state.newState(sortType: sortType));
_onNewSuggestions(_suggestionRepository.suggestions);
await _onNewSuggestions(_suggestionRepository.suggestions);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class _CreateCommentBottomSheetState extends State<CreateCommentBottomSheet> {
context.theme.colorScheme.surface,
previousNavBarColor: context.theme.colorScheme.surface,
previousStatusBarColor: context.theme.colorScheme.surface,
contentBuilder: (_, __) {
contentBuilder: (_, _) {
return ListView(
padding: const EdgeInsets.only(
top: Dimensions.marginSmall,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class _LabelBottomSheetState extends State<LabelBottomSheet> {
},
backgroundColor: context.theme.bottomSheetTheme.backgroundColor ??
context.theme.colorScheme.surface,
contentBuilder: (_, __) {
contentBuilder: (_, _) {
return _LabelsListView(
onTap: (label) => setState(
() => selectedLabels.contains(label)
Expand Down
2 changes: 1 addition & 1 deletion lib/src/presentation/pages/widgets/network_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SuggestionsNetworkImage extends StatelessWidget {
color: noImageColor ?? context.theme.colorScheme.surface,
);
},
errorBuilder: (_, __, ___) => ColoredBox(
errorBuilder: (_, _, _) => ColoredBox(
color: noImageColor ?? context.theme.colorScheme.surface,
),
),
Expand Down
19 changes: 2 additions & 17 deletions lib/src/presentation/pages/widgets/photo_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class _PhotoViewState extends State<PhotoView> {
late PageController _galleryPageController;
late int _currentIndex;
final Map<int, Offset> _touchPositions = <int, Offset>{};
ScrollPhysics _scrollPhysics = const _CustomPageViewScrollPhysics();
ScrollPhysics _scrollPhysics = const PageScrollPhysics();

var _isZoomed = false;

Expand Down Expand Up @@ -105,7 +105,7 @@ class _PhotoViewState extends State<PhotoView> {
setState(() {
_scrollPhysics = _touchPositions.length > 1 || _isZoomed
? const NeverScrollableScrollPhysics()
: const _CustomPageViewScrollPhysics();
: const PageScrollPhysics();
});
}

Expand Down Expand Up @@ -180,18 +180,3 @@ class _ActionButtons extends StatelessWidget {
);
}
}

class _CustomPageViewScrollPhysics extends ScrollPhysics {
const _CustomPageViewScrollPhysics({super.parent});

@override
_CustomPageViewScrollPhysics applyTo(ScrollPhysics? ancestor) =>
_CustomPageViewScrollPhysics(parent: buildParent(ancestor));

@override
SpringDescription get spring => const SpringDescription(
mass: 50,
stiffness: 100,
damping: 0.8,
);
}
Loading