added back flip to hunt cards

This commit is contained in:
mohamadmahdi jebeli 2025-09-23 08:16:47 +03:30
parent 3308db6979
commit 87ec98def4
2 changed files with 21 additions and 3 deletions

View File

@ -122,7 +122,8 @@ class _HuntContentState extends State<_HuntContent> with TickerProviderStateMixi
}
});
huntProvider.selectCard(card);
// Toggle the flip state of the card
huntProvider.toggleCardFlip(card.id);
}
@ -246,7 +247,7 @@ class _HuntContentState extends State<_HuntContent> with TickerProviderStateMixi
card: card,
onTap: () => _onCardSelected(card),
isSelected: huntProvider.selectedCard?.id == card.id,
isFlipped: huntProvider.selectedCard?.id == card.id,
isFlipped: huntProvider.isCardFlipped(card.id),
),
);
},

View File

@ -18,6 +18,7 @@ class HuntState extends ChangeNotifier {
bool _isLocationEnabled = false;
bool _isCameraPermissionGranted = false;
DateTime? _huntStartTime;
String? _currentlyFlippedCardId;
List<HuntCard> get cards => _cards;
HuntCard? get selectedCard => _selectedCard;
@ -27,6 +28,11 @@ class HuntState extends ChangeNotifier {
bool get isLocationEnabled => _isLocationEnabled;
bool get isCameraPermissionGranted => _isCameraPermissionGranted;
DateTime? get huntStartTime => _huntStartTime;
String? get currentlyFlippedCardId => _currentlyFlippedCardId;
bool isCardFlipped(String cardId) {
return _currentlyFlippedCardId == cardId;
}
bool get hasTimeLeft {
if (_huntStartTime == null) return false;
@ -62,6 +68,16 @@ class HuntState extends ChangeNotifier {
notifyListeners();
}
void toggleCardFlip(String cardId) {
if (_currentlyFlippedCardId == cardId) {
_currentlyFlippedCardId = null;
}
else {
_currentlyFlippedCardId = cardId;
}
notifyListeners();
}
void startHunt() {
if (_selectedCard != null) {
_huntStartTime = DateTime.now();
@ -100,6 +116,7 @@ class HuntState extends ChangeNotifier {
_selectedCard = null;
_gameState = HuntGameState.cardSelection;
_huntStartTime = null;
_currentlyFlippedCardId = null;
notifyListeners();
}
@ -170,7 +187,7 @@ class HuntState extends ChangeNotifier {
question: 'In the digital realm where innovation never sleeps, discover the place where technology meets tomorrow.',
answer: 'TechnoCity',
description: 'Electronics and gadgets store',
targetLatitude: 32.625042058762496,
targetLatitude: 32.825042058762496,
targetLongitude: 51.7264112781341,
hintLatitude: 32.625042058762496,
hintLongitude: 51.7264112781341,