added back flip to hunt cards
This commit is contained in:
parent
3308db6979
commit
87ec98def4
|
|
@ -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,
|
card: card,
|
||||||
onTap: () => _onCardSelected(card),
|
onTap: () => _onCardSelected(card),
|
||||||
isSelected: huntProvider.selectedCard?.id == card.id,
|
isSelected: huntProvider.selectedCard?.id == card.id,
|
||||||
isFlipped: huntProvider.selectedCard?.id == card.id,
|
isFlipped: huntProvider.isCardFlipped(card.id),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ class HuntState extends ChangeNotifier {
|
||||||
bool _isLocationEnabled = false;
|
bool _isLocationEnabled = false;
|
||||||
bool _isCameraPermissionGranted = false;
|
bool _isCameraPermissionGranted = false;
|
||||||
DateTime? _huntStartTime;
|
DateTime? _huntStartTime;
|
||||||
|
String? _currentlyFlippedCardId;
|
||||||
|
|
||||||
List<HuntCard> get cards => _cards;
|
List<HuntCard> get cards => _cards;
|
||||||
HuntCard? get selectedCard => _selectedCard;
|
HuntCard? get selectedCard => _selectedCard;
|
||||||
|
|
@ -27,6 +28,11 @@ class HuntState extends ChangeNotifier {
|
||||||
bool get isLocationEnabled => _isLocationEnabled;
|
bool get isLocationEnabled => _isLocationEnabled;
|
||||||
bool get isCameraPermissionGranted => _isCameraPermissionGranted;
|
bool get isCameraPermissionGranted => _isCameraPermissionGranted;
|
||||||
DateTime? get huntStartTime => _huntStartTime;
|
DateTime? get huntStartTime => _huntStartTime;
|
||||||
|
String? get currentlyFlippedCardId => _currentlyFlippedCardId;
|
||||||
|
|
||||||
|
bool isCardFlipped(String cardId) {
|
||||||
|
return _currentlyFlippedCardId == cardId;
|
||||||
|
}
|
||||||
|
|
||||||
bool get hasTimeLeft {
|
bool get hasTimeLeft {
|
||||||
if (_huntStartTime == null) return false;
|
if (_huntStartTime == null) return false;
|
||||||
|
|
@ -62,6 +68,16 @@ class HuntState extends ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void toggleCardFlip(String cardId) {
|
||||||
|
if (_currentlyFlippedCardId == cardId) {
|
||||||
|
_currentlyFlippedCardId = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_currentlyFlippedCardId = cardId;
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
void startHunt() {
|
void startHunt() {
|
||||||
if (_selectedCard != null) {
|
if (_selectedCard != null) {
|
||||||
_huntStartTime = DateTime.now();
|
_huntStartTime = DateTime.now();
|
||||||
|
|
@ -100,6 +116,7 @@ class HuntState extends ChangeNotifier {
|
||||||
_selectedCard = null;
|
_selectedCard = null;
|
||||||
_gameState = HuntGameState.cardSelection;
|
_gameState = HuntGameState.cardSelection;
|
||||||
_huntStartTime = null;
|
_huntStartTime = null;
|
||||||
|
_currentlyFlippedCardId = null;
|
||||||
notifyListeners();
|
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.',
|
question: 'In the digital realm where innovation never sleeps, discover the place where technology meets tomorrow.',
|
||||||
answer: 'TechnoCity',
|
answer: 'TechnoCity',
|
||||||
description: 'Electronics and gadgets store',
|
description: 'Electronics and gadgets store',
|
||||||
targetLatitude: 32.625042058762496,
|
targetLatitude: 32.825042058762496,
|
||||||
targetLongitude: 51.7264112781341,
|
targetLongitude: 51.7264112781341,
|
||||||
hintLatitude: 32.625042058762496,
|
hintLatitude: 32.625042058762496,
|
||||||
hintLongitude: 51.7264112781341,
|
hintLongitude: 51.7264112781341,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue