post_enrollment_app/lib/pages/service/BlinkingCard.dart
2025-12-28 11:26:50 +05:30

110 lines
3.6 KiB
Dart
Executable File

import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import '../../customAppBar/responsive.dart';
import '../postEnrollment/service/api_service.dart';
import 'SessionManager.dart';
import 'common_update_mobile_dialog.dart';
import 'data_manager.dart';
class BlinkingCard extends StatefulWidget {
final VoidCallback onUpdated; // 👈 add this
const BlinkingCard({super.key, required this.onUpdated});
@override
State<BlinkingCard> createState() => _BlinkingCardState();
}
class _BlinkingCardState extends State<BlinkingCard>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
late Animation<Color?> _colorTween;
late ApiService apiService;
final dataManager = DataManager();
final session = SessionManager();
@override
void initState() {
super.initState();
apiService = ApiService(context);
_controller = AnimationController(
duration: const Duration(seconds: 1),
vsync: this,
)..repeat(reverse: true); // 🔥 blinking loop
_colorTween = ColorTween(
begin: const Color(0xFFFFE5E5), // Light red
end: const Color(0xFFFFC1C1), // slightly darker for blink effect
).animate(_controller);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _colorTween,
builder: (context, child) {
return Card(
elevation: 3,
shadowColor: Colors.red.shade50,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
child: Container(
decoration: BoxDecoration(
color: _colorTween.value, // 🔥 blinking background color
borderRadius: BorderRadius.circular(10),
),
padding: const EdgeInsets.all(12),
child: Row(
children: [
Expanded(
flex: 7,
child: Text(
"Update Mobile Number",
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context) ? 18 : 12,
fontWeight: FontWeight.w500,
color: const Color(0xFF404040),
),
),
),
Expanded(
flex: 5,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
ElevatedButton(
onPressed: true ? () async {
final selfDetails = dataManager.selfProfile;
final updatedNumber = await showUpdateMobileDialog(context, apiService, session.client_id!, selfDetails?['email_corporate'], selfDetails?['mobile']);
if (updatedNumber != null && updatedNumber.isNotEmpty) {
// setState(() => selfMobile = updatedNumber);
dataManager.loadSelfEmployeeProfile(
clientId: session.client_id!,
empCode: session.empCodeString!,
clientBranchId: session.empClientBranchId!,
);
widget.onUpdated();
}
} : null,
child: const Text("Update"),
),
],
),
)
],
),
),
);
},
);
}
}