# Rode o app — Flutter escolhe o primeiro dispositivo disponível
# Uso: make run | make run-ios | make run-android | make run-web
# Hot reload: pressione 'r' no terminal enquanto o app roda
# run-ios/run-android: mostra lista de dispositivos — selecione iPhone, simulador ou Android
#
# Credenciais: crie um arquivo .dart_defines (gitignored) com uma flag por linha:
#   --dart-define=RC_IOS_API_KEY=xxx
#   --dart-define=RC_ANDROID_API_KEY=xxx
#   --dart-define=MIXPANEL_TOKEN=xxx
#   etc.

DEFINES := $(shell [ -f .dart_defines ] && cat .dart_defines | tr '\n' ' ')

.PHONY: run run-ios run-android run-web release-ios check-tokens check-components check-browser-qa

# iOS App Store release (requires: kasy ios configure)
release-ios:
	bash scripts/release-ios.sh

# Guardrail: flags raw radius/spacing numbers in lib/features that bypass
# KasyRadius/KasySpacing. Run before pushing screen changes.
check-tokens:
	dart run scripts/check_design_tokens.dart

# Guardrail: raw Material widgets in lib/features that bypass a Kasy
# component (Drawer, dialog, bottom sheet, TextField, ListTile, IconButton,
# ElevatedButton/Card/...). Run before pushing screen changes.
check-components:
	dart run tool/design_check.dart

# Guardrail: Browser QA semantics anti-patterns (duplicate textField, composite
# IgnorePointer without ExcludeSemantics).
check-browser-qa:
	dart run scripts/check_browser_qa_semantics.dart

# FLUTTER_SWIFT_PACKAGE_MANAGER=false avoids a Facebook SDK double-link
# (facebook_app_events via SPM + flutter_facebook_auth via CocoaPods both
# embed FBSDKCoreKit/FBAEMKit -- "Multiple commands produce" on iOS device
# builds). No-op on Android/web. See scripts/release-ios.sh for the same fix.
run:
	FLUTTER_SWIFT_PACKAGE_MANAGER=false flutter run $(DEFINES)

run-ios:
	FLUTTER_SWIFT_PACKAGE_MANAGER=false flutter run $(DEFINES)

run-android:
	FLUTTER_SWIFT_PACKAGE_MANAGER=false flutter run $(DEFINES)

run-web:
	FLUTTER_SWIFT_PACKAGE_MANAGER=false flutter run -d chrome $(DEFINES)
