import 'package:autos/core/theme/app_typography.dart'; import 'package:autos/core/widgets/hamburger_button.dart'; import 'package:autos/core/widgets/side_menu.dart'; import 'package:autos/presentation/providers/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; class Turn14Screen extends ConsumerStatefulWidget { const Turn14Screen({super.key}); @override ConsumerState createState() => _Turn14ScreenState(); } class _Turn14ScreenState extends ConsumerState { final GlobalKey _scaffoldKey = GlobalKey(); String selected = 'turn14'; @override Widget build(BuildContext context) { final user = ref.watch(userDetailsProvider); final double topPadding = MediaQuery.of(context).padding.top + 16; return Scaffold( key: _scaffoldKey, drawer: SideMenu( selected: selected, onItemSelected: (key) { setState(() => selected = key); }, ), body: Stack( children: [ Positioned( top: topPadding, left: 0, right: 0, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Turn14 Settings", style: AppTypo.h2.copyWith(fontWeight: FontWeight.w700), ), ], ), ), SingleChildScrollView( physics: const BouncingScrollPhysics(), padding: EdgeInsets.fromLTRB(16, topPadding + 55, 16, 20), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // Description Row Row( children: [ Text("⚡", style: const TextStyle(fontSize: 28)), const SizedBox(width: 8), Expanded( child: Text( "Manage your Turn14 API credentials securely.", style: AppTypo.body.copyWith( color: Colors.black54, height: 1.4, ), ), ), ], ), const SizedBox(height: 20), // Client ID Input _inputField( label: "Client ID", controller: TextEditingController(), ), const SizedBox(height: 20), // Secret Key Input With Eye Icon _passwordField( label: "Secret Key", controller: TextEditingController(), ), const SizedBox(height: 25), // Save Button SizedBox( width: double.infinity, child: ElevatedButton( style: ElevatedButton.styleFrom( padding: const EdgeInsets.symmetric(vertical: 16), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), ), backgroundColor: const Color(0xFF00C9FF), ), onPressed: () {}, child: const Text( "Save Credentials", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16, ), ), ), ), const SizedBox(height: 20), // Info Box Container( width: double.infinity, padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: const Color(0xFFE8F1FF), borderRadius: BorderRadius.circular(10), ), child: Row( children: const [ Icon(Icons.info, color: Colors.blue), SizedBox(width: 10), Text( "No credentials saved yet.", style: TextStyle(color: Colors.black87), ), ], ), ), const SizedBox(height: 20), // Tips Box Container( width: double.infinity, padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: const Color(0xFFE8FCFF), borderRadius: BorderRadius.circular(10), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: const [ Text( "💡 Connection Tips", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 16, ), ), SizedBox(height: 10), Text("• Ensure your credentials are valid and active."), Text("• Credentials are encrypted before saving."), Text("• Contact Turn14 support for API setup help."), ], ), ), ], ), ), HamburgerButton(scaffoldKey: _scaffoldKey), ], ), ); } Widget _inputField({ required String label, required TextEditingController controller, }) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(label, style: const TextStyle(fontWeight: FontWeight.w600)), const SizedBox(height: 8), TextField( controller: controller, decoration: InputDecoration( filled: true, fillColor: const Color(0xFFF0F6FF), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none, ), ), ), ], ); } Widget _passwordField({ required String label, required TextEditingController controller, }) { bool _obscure = true; return StatefulBuilder( builder: (context, setStateSB) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(label, style: const TextStyle(fontWeight: FontWeight.w600)), const SizedBox(height: 8), TextField( controller: controller, obscureText: _obscure, decoration: InputDecoration( filled: true, fillColor: const Color(0xFFF0F6FF), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none, ), suffixIcon: IconButton( icon: Icon( _obscure ? Icons.visibility_off : Icons.visibility, ), onPressed: () => setStateSB(() => _obscure = !_obscure), ), ), ), ], ); }, ); } }