Skip to content

Commit

Permalink
Merge pull request #75 from simonoppowa/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
simonoppowa committed Apr 28, 2024
2 parents fbff113 + 8e66448 commit 0bb164d
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 150 deletions.
64 changes: 28 additions & 36 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ PODS:
- Flutter
- flutter_secure_storage (6.0.0):
- Flutter
- GoogleDataTransport (9.3.0):
- GoogleDataTransport (9.4.1):
- GoogleUtilities/Environment (~> 7.7)
- nanopb (< 2.30910.0, >= 2.30908.0)
- nanopb (< 2.30911.0, >= 2.30908.0)
- PromisesObjC (< 3.0, >= 1.2)
- GoogleMLKit/BarcodeScanning (4.0.0):
- GoogleMLKit/MLKitCore
Expand All @@ -27,12 +27,16 @@ PODS:
- GoogleToolboxForMac/Defines (= 2.3.2)
- "GoogleToolboxForMac/NSString+URLArguments (= 2.3.2)"
- "GoogleToolboxForMac/NSString+URLArguments (2.3.2)"
- GoogleUtilities/Environment (7.12.0):
- GoogleUtilities/Environment (7.13.0):
- GoogleUtilities/Privacy
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/Logger (7.12.0):
- GoogleUtilities/Logger (7.13.0):
- GoogleUtilities/Environment
- GoogleUtilities/UserDefaults (7.12.0):
- GoogleUtilities/Privacy
- GoogleUtilities/Privacy (7.13.0)
- GoogleUtilities/UserDefaults (7.13.0):
- GoogleUtilities/Logger
- GoogleUtilities/Privacy
- GoogleUtilitiesComponents (1.1.0):
- GoogleUtilities/Logger
- GTMSessionFetcher/Core (2.3.0)
Expand All @@ -57,36 +61,32 @@ PODS:
- mobile_scanner (3.5.6):
- Flutter
- GoogleMLKit/BarcodeScanning (~> 4.0.0)
- nanopb (2.30909.1):
- nanopb/decode (= 2.30909.1)
- nanopb/encode (= 2.30909.1)
- nanopb/decode (2.30909.1)
- nanopb/encode (2.30909.1)
- nanopb (2.30910.0):
- nanopb/decode (= 2.30910.0)
- nanopb/encode (= 2.30910.0)
- nanopb/decode (2.30910.0)
- nanopb/encode (2.30910.0)
- package_info_plus (0.4.5):
- Flutter
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- PromisesObjC (2.3.1)
- Sentry/HybridSDK (8.20.0):
- SentryPrivate (= 8.20.0)
- PromisesObjC (2.4.0)
- Sentry/HybridSDK (8.21.0):
- SentryPrivate (= 8.21.0)
- sentry_flutter (0.0.1):
- Flutter
- FlutterMacOS
- Sentry/HybridSDK (= 8.20.0)
- SentryPrivate (8.20.0)
- Sentry/HybridSDK (= 8.21.0)
- SentryPrivate (8.21.0)
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- sign_in_with_apple (0.0.1):
- Flutter
- sqflite (0.0.3):
- Flutter
- FlutterMacOS
- url_launcher_ios (0.0.1):
- Flutter
- webview_flutter_wkwebview (0.0.1):
- Flutter

DEPENDENCIES:
- app_links (from `.symlinks/plugins/app_links/ios`)
Expand All @@ -98,10 +98,8 @@ DEPENDENCIES:
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- sentry_flutter (from `.symlinks/plugins/sentry_flutter/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sign_in_with_apple (from `.symlinks/plugins/sign_in_with_apple/ios`)
- sqflite (from `.symlinks/plugins/sqflite/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`)

SPEC REPOS:
trunk:
Expand Down Expand Up @@ -139,43 +137,37 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/sentry_flutter/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sign_in_with_apple:
:path: ".symlinks/plugins/sign_in_with_apple/ios"
sqflite:
:path: ".symlinks/plugins/sqflite/darwin"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"
webview_flutter_wkwebview:
:path: ".symlinks/plugins/webview_flutter_wkwebview/ios"

SPEC CHECKSUMS:
app_links: 5ef33d0d295a89d9d16bb81b0e3b0d5f70d6c875
app_links: e70ca16b4b0f88253b3b3660200d4a10b4ea9795
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
GoogleDataTransport: 57c22343ab29bc686febbf7cbb13bad167c2d8fe
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
GoogleMLKit: 2bd0dc6253c4d4f227aad460f69215a504b2980e
GoogleToolboxForMac: 8bef7c7c5cf7291c687cf5354f39f9db6399ad34
GoogleUtilities: 0759d1a57ebb953965c2dfe0ba4c82e95ccc2e34
GoogleUtilities: d053d902a8edaa9904e1bd00c37535385b8ed152
GoogleUtilitiesComponents: 679b2c881db3b615a2777504623df6122dd20afe
GTMSessionFetcher: 3a63d75eecd6aa32c2fc79f578064e1214dfdec2
MLImage: 7bb7c4264164ade9bf64f679b40fb29c8f33ee9b
MLKitBarcodeScanning: 04e264482c5f3810cb89ebc134ef6b61e67db505
MLKitCommon: c1b791c3e667091918d91bda4bba69a91011e390
MLKitVision: 8baa5f46ee3352614169b85250574fde38c36f49
mobile_scanner: 38dcd8a49d7d485f632b7de65e4900010187aef2
nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5
nanopb: 438bc412db1928dac798aa6fd75726007be04262
package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
Sentry: a8d7b373b9f9868442b02a0c425192f693103cbf
sentry_flutter: 03e7660857a8cdb236e71456a7e8447b65c8a788
SentryPrivate: 006b24af16828441f70e2ab6adf241bd0a8ad130
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
Sentry: ebc12276bd17613a114ab359074096b6b3725203
sentry_flutter: dff1df05dc39c83d04f9330b36360fc374574c5e
SentryPrivate: d651efb234cf385ec9a1cdd3eff94b5e78a0e0fe
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
sign_in_with_apple: f3bf75217ea4c2c8b91823f225d70230119b8440
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812
webview_flutter_wkwebview: be0f0d33777f1bfd0c9fdcb594786704dbf65f36
url_launcher_ios: 6116280ddcfe98ab8820085d8d76ae7449447586

PODFILE CHECKSUM: e60e17f8bfffff789408fce3f968c37c5c63400e

Expand Down
6 changes: 3 additions & 3 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -428,7 +428,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -477,7 +477,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
14 changes: 8 additions & 6 deletions lib/core/presentation/widgets/intake_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import 'package:opennutritracker/core/utils/locator.dart';

class IntakeCard extends StatelessWidget {
final IntakeEntity intake;
final Function(BuildContext, IntakeEntity) onItemLongPressed;
final Function(BuildContext, IntakeEntity)? onItemLongPressed;
final bool firstListElement;

const IntakeCard(
{required super.key,
required this.intake,
required this.onItemLongPressed,
this.onItemLongPressed,
required this.firstListElement});

@override
Expand All @@ -32,9 +32,9 @@ class IntakeCard extends StatelessWidget {
),
elevation: 1,
child: InkWell(
onLongPress: () {
onLongPressedItem(context);
},
onLongPress: onItemLongPressed != null
? () => onLongPressedItem(context)
: null,
child: Stack(
children: [
intake.meal.mainImageUrl != null
Expand Down Expand Up @@ -122,6 +122,8 @@ class IntakeCard extends StatelessWidget {
}

void onLongPressedItem(BuildContext context) {
onItemLongPressed(context, intake);
if (onItemLongPressed != null) {
onItemLongPressed!(context, intake);
}
}
}
154 changes: 103 additions & 51 deletions lib/features/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
final log = Logger('HomePage');

late HomeBloc _homeBloc;
bool _isDragging = false;

@override
void initState() {
Expand Down Expand Up @@ -111,57 +112,87 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
if (showDisclaimerDialog) {
_showDisclaimerDialog(context);
}
return ListView(children: [
DashboardWidget(
totalKcalDaily: totalKcalDaily,
totalKcalLeft: totalKcalLeft,
totalKcalSupplied: totalKcalSupplied,
totalKcalBurned: totalKcalBurned,
totalCarbsIntake: totalCarbsIntake,
totalFatsIntake: totalFatsIntake,
totalProteinsIntake: totalProteinsIntake,
totalCarbsGoal: totalCarbsGoal,
totalFatsGoal: totalFatsGoal,
totalProteinsGoal: totalProteinsGoal,
),
ActivityVerticalList(
day: DateTime.now(),
title: S.of(context).activityLabel,
userActivityList: userActivities,
onItemLongPressedCallback: onActivityItemLongPressed,
),
IntakeVerticalList(
day: DateTime.now(),
title: S.of(context).breakfastLabel,
listIcon: IntakeTypeEntity.breakfast.getIconData(),
addMealType: AddMealType.breakfastType,
intakeList: breakfastIntakeList,
onItemLongPressedCallback: onIntakeItemLongPressed,
),
IntakeVerticalList(
day: DateTime.now(),
title: S.of(context).lunchLabel,
listIcon: IntakeTypeEntity.lunch.getIconData(),
addMealType: AddMealType.lunchType,
intakeList: lunchIntakeList,
onItemLongPressedCallback: onIntakeItemLongPressed,
),
IntakeVerticalList(
day: DateTime.now(),
title: S.of(context).dinnerLabel,
addMealType: AddMealType.dinnerType,
listIcon: IntakeTypeEntity.dinner.getIconData(),
intakeList: dinnerIntakeList,
onItemLongPressedCallback: onIntakeItemLongPressed,
),
IntakeVerticalList(
day: DateTime.now(),
title: S.of(context).snackLabel,
listIcon: IntakeTypeEntity.snack.getIconData(),
addMealType: AddMealType.snackType,
intakeList: snackIntakeList,
onItemLongPressedCallback: onIntakeItemLongPressed,
)
return Stack(children: [
ListView(children: [
DashboardWidget(
totalKcalDaily: totalKcalDaily,
totalKcalLeft: totalKcalLeft,
totalKcalSupplied: totalKcalSupplied,
totalKcalBurned: totalKcalBurned,
totalCarbsIntake: totalCarbsIntake,
totalFatsIntake: totalFatsIntake,
totalProteinsIntake: totalProteinsIntake,
totalCarbsGoal: totalCarbsGoal,
totalFatsGoal: totalFatsGoal,
totalProteinsGoal: totalProteinsGoal,
),
ActivityVerticalList(
day: DateTime.now(),
title: S.of(context).activityLabel,
userActivityList: userActivities,
onItemLongPressedCallback: onActivityItemLongPressed,
),
IntakeVerticalList(
day: DateTime.now(),
title: S.of(context).breakfastLabel,
listIcon: IntakeTypeEntity.breakfast.getIconData(),
addMealType: AddMealType.breakfastType,
intakeList: breakfastIntakeList,
onItemDragCallback: onIntakeItemDrag,
),
IntakeVerticalList(
day: DateTime.now(),
title: S.of(context).lunchLabel,
listIcon: IntakeTypeEntity.lunch.getIconData(),
addMealType: AddMealType.lunchType,
intakeList: lunchIntakeList,
onItemDragCallback: onIntakeItemDrag,
),
IntakeVerticalList(
day: DateTime.now(),
title: S.of(context).dinnerLabel,
addMealType: AddMealType.dinnerType,
listIcon: IntakeTypeEntity.dinner.getIconData(),
intakeList: dinnerIntakeList,
onItemDragCallback: onIntakeItemDrag,
),
IntakeVerticalList(
day: DateTime.now(),
title: S.of(context).snackLabel,
listIcon: IntakeTypeEntity.snack.getIconData(),
addMealType: AddMealType.snackType,
intakeList: snackIntakeList,
onItemDragCallback: onIntakeItemDrag,
),
const SizedBox(height: 48.0)
]),
Align(
alignment: Alignment.bottomCenter,
child: Visibility(
visible: _isDragging,
child: Container(
height: 70,
color: Theme.of(context).colorScheme.error.withOpacity(0.3),
child: DragTarget<IntakeEntity>(
onAcceptWithDetails: (data) {
_confirmDelete(context, data.data);
},
onLeave: (data) {
setState(() {
_isDragging = false;
});
},
builder: (context, candidateData, rejectedData) {
return const Center(
child: Icon(
Icons.delete_outline,
size: 36,
color: Colors.white,
),
);
},
),
)))
]);
}

Expand Down Expand Up @@ -195,6 +226,27 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
}
}

void onIntakeItemDrag(bool isDragging) {
WidgetsBinding.instance.addPostFrameCallback((_) {
setState(() {
_isDragging = isDragging;
});
});
}

void _confirmDelete(BuildContext context, IntakeEntity intake) async {
bool? delete = await showDialog<bool>(
context: context, builder: (context) => const DeleteDialog());

if (delete == true) {
_homeBloc.deleteIntakeItem(intake);
_homeBloc.add(const LoadItemsEvent());
}
setState(() {
_isDragging = false;
});
}

/// Show disclaimer dialog after build method
void _showDisclaimerDialog(BuildContext context) async {
WidgetsBinding.instance.addPostFrameCallback((_) async {
Expand Down
Loading

0 comments on commit 0bb164d

Please sign in to comment.