// import 'dart:async'; // import 'package:flutter/material.dart'; // import 'package:flutter/services.dart'; // import 'channel_list_screen.dart'; // class HomeScreen extends StatefulWidget { // const HomeScreen({super.key}); // @override // State createState() => _HomeScreenState(); // } // class _HomeScreenState extends State { // static final _channel = const MethodChannel('com.example.watch/launcher'); // int _batteryLevel = 0; // bool _isCharging = false; // Timer? _batteryTimer; // @override // void initState() { // super.initState(); // _loadBattery(); // _batteryTimer = Timer.periodic( // const Duration(seconds: 30), // (_) => _loadBattery(), // ); // } // Future _loadBattery() async { // try { // final info = await _channel.invokeMapMethod( // 'getBatteryInfo', // ); // if (!mounted || info == null) return; // setState(() { // _batteryLevel = (info['level'] as int?) ?? 0; // _isCharging = (info['isCharging'] as bool?) ?? false; // }); // } catch (_) {} // } // @override // void dispose() { // _batteryTimer?.cancel(); // super.dispose(); // } // Color get _batteryColor { // if (_isCharging) return const Color(0xFF00C853); // if (_batteryLevel <= 15) return const Color(0xFFFF1744); // if (_batteryLevel <= 30) return const Color(0xFFFFAB00); // return Colors.white54; // } // @override // Widget build(BuildContext context) { // return Scaffold( // backgroundColor: Colors.black, // body: SafeArea( // child: Stack( // children: [ // // ── Battery indicator (top right) ────────────────────────── // Positioned( // top: 4, // right: 8, // child: Row( // mainAxisSize: MainAxisSize.min, // children: [ // if (_isCharging) // const Icon(Icons.bolt, color: Color(0xFF00C853), size: 11), // Text( // '$_batteryLevel%', // style: TextStyle(color: _batteryColor, fontSize: 9), // ), // ], // ), // ), // // ── Charging banner ──────────────────────────────────────── // if (_isCharging) // Positioned( // bottom: 10, // left: 0, // right: 0, // child: Row( // mainAxisAlignment: MainAxisAlignment.center, // children: [ // Container( // padding: const EdgeInsets.symmetric( // horizontal: 10, // vertical: 3, // ), // decoration: BoxDecoration( // color: const Color(0xFF00C853).withValues(alpha: 0.15), // borderRadius: BorderRadius.circular(20), // border: Border.all( // color: const Color(0xFF00C853).withValues(alpha: 0.4), // width: 1, // ), // ), // child: Row( // mainAxisSize: MainAxisSize.min, // children: [ // const Icon( // Icons.bolt, // color: Color(0xFF00C853), // size: 11, // ), // const SizedBox(width: 3), // Text( // 'در حال شارژ — $_batteryLevel%', // style: const TextStyle( // color: Color(0xFF00C853), // fontSize: 9, // ), // ), // ], // ), // ), // ], // ), // ), // // ── App grid ─────────────────────────────────────────────── // Center( // child: Column( // mainAxisAlignment: MainAxisAlignment.center, // children: [ // const Text( // 'برنامه‌ها', // style: TextStyle( // color: Colors.white38, // fontSize: 9, // letterSpacing: 0.5, // ), // ), // const SizedBox(height: 16), // Row( // mainAxisAlignment: MainAxisAlignment.center, // children: [ // _AppIcon( // icon: Icons.radio, // label: 'بی‌سیم', // color: const Color(0xFF00C853), // onTap: () { // Navigator.push( // context, // MaterialPageRoute( // builder: (_) => const ChannelListScreen(), // ), // ); // }, // ), // const SizedBox(width: 20), // _AppIcon( // icon: Icons.phone, // label: 'تلفن', // color: const Color(0xFF2979FF), // onTap: () { // ScaffoldMessenger.of(context).showSnackBar( // const SnackBar( // content: Text( // 'به زودی', // textAlign: TextAlign.center, // style: TextStyle( // fontSize: 11, // color: Colors.white, // ), // ), // duration: Duration(seconds: 1), // backgroundColor: Color(0xFF2C2C2E), // behavior: SnackBarBehavior.floating, // margin: EdgeInsets.symmetric( // horizontal: 24, // vertical: 40, // ), // ), // ); // }, // ), // ], // ), // ], // ), // ), // ], // ), // ), // ); // } // } // class _AppIcon extends StatelessWidget { // final IconData icon; // final String label; // final Color color; // final VoidCallback onTap; // const _AppIcon({ // required this.icon, // required this.label, // required this.color, // required this.onTap, // }); // @override // Widget build(BuildContext context) { // return GestureDetector( // onTap: onTap, // child: Column( // mainAxisSize: MainAxisSize.min, // children: [ // Container( // width: 58, // height: 58, // decoration: BoxDecoration( // color: color.withValues(alpha: 0.13), // shape: BoxShape.circle, // border: Border.all( // color: color.withValues(alpha: 0.45), // width: 1.5, // ), // boxShadow: [ // BoxShadow( // color: color.withValues(alpha: 0.18), // blurRadius: 12, // spreadRadius: 1, // ), // ], // ), // child: Icon(icon, color: color, size: 28), // ), // const SizedBox(height: 7), // Text( // label, // style: const TextStyle( // color: Colors.white, // fontSize: 11, // fontWeight: FontWeight.w500, // ), // ), // ], // ), // ); // } // }