Files
Run_vision_pro_inicial_DB/lib/screens/inicial_screen.dart
Carlos Correia ebca3cfdce TUDO
2026-03-04 15:54:24 +00:00

156 lines
4.4 KiB
Dart

import 'package:flutter/material.dart';
import '../constants/app_colors.dart';
import '../constants/app_strings.dart';
import '../sheets/entrar_sheet.dart';
import '../sheets/registrar_sheet.dart';
import '../services/supabase_service.dart';
class AnimatedButton extends StatefulWidget {
final String text;
final VoidCallback onPressed;
final Color backgroundColor;
final Color textColor;
const AnimatedButton({
super.key,
required this.text,
required this.onPressed,
required this.backgroundColor,
required this.textColor,
});
@override
State<AnimatedButton> createState() => _AnimatedButtonState();
}
class _AnimatedButtonState extends State<AnimatedButton>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
late Animation<double> _scaleAnimation;
late Animation<double> _bounceAnimation;
@override
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(milliseconds: 150),
vsync: this,
);
_scaleAnimation = Tween<double>(
begin: 1.0,
end: 0.92,
).animate(CurvedAnimation(parent: _controller, curve: Curves.easeInOut));
_bounceAnimation = Tween<double>(begin: 0.0, end: -3.0).animate(
CurvedAnimation(
parent: _controller,
curve: const Interval(0.3, 0.8, curve: Curves.elasticOut),
),
);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
void _handleTap() {
_controller.forward().then((_) {
_controller.reverse().then((_) {
widget.onPressed();
});
});
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _controller,
builder: (context, child) {
return Transform.translate(
offset: Offset(0, _bounceAnimation.value),
child: Transform.scale(
scale: _scaleAnimation.value,
child: SizedBox(
width: double.infinity,
height: 60,
child: ElevatedButton(
onPressed: _handleTap,
style: ElevatedButton.styleFrom(
backgroundColor: widget.backgroundColor,
foregroundColor: widget.textColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
),
elevation: 5,
),
child: Text(
widget.text,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
),
),
),
);
},
);
}
}
class InicialScreen extends StatelessWidget {
const InicialScreen({super.key});
@override
Widget build(BuildContext context) {
// Test Supabase connection on app start
WidgetsBinding.instance.addPostFrameCallback((_) async {
final isConnected = await SupabaseService.testConnection();
print('DEBUG: Status da conexão: $isConnected');
});
return Scaffold(
backgroundColor: AppColors.background,
body: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AnimatedButton(
text: AppStrings.registrar,
onPressed: () {
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) => const RegistrarSheet(),
);
},
backgroundColor: AppColors.buttonColor,
textColor: AppColors.white,
),
const SizedBox(height: 16),
AnimatedButton(
text: AppStrings.entrar,
onPressed: () {
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) => const EntrarSheet(),
);
},
backgroundColor: AppColors.buttonColor,
textColor: AppColors.white,
),
],
),
),
),
);
}
}