import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:gobang/components/game_action_bar.dart'; import 'package:gobang/components/game_status_text.dart'; import 'package:gobang/controllers/game_controller.dart'; import 'package:gobang/widgets/gobang_board.dart'; class HomePage extends GetView { const HomePage({super.key}); @override Widget build(BuildContext context) { return Obx(() { final themeColor = controller.themeColor; // 订阅形状切换,刷新 AppBar icon final _ = controller.useCircle.value; final boardSize = (1.sw * 0.8).clamp(0.0, 1.sh * 0.55); return Scaffold( appBar: AppBar( elevation: 0, backgroundColor: themeColor, title: const Text('南瓜五子棋'), actions: [ IconButton( onPressed: controller.toggleTheme, icon: controller.currentLight, ), IconButton( onPressed: controller.toggleShape, icon: controller.currentShape, ), ], ), body: Container( width: double.infinity, decoration: BoxDecoration( gradient: LinearGradient( colors: [themeColor, Colors.white], begin: Alignment.topCenter, end: Alignment.bottomCenter, ), ), child: SafeArea( child: SingleChildScrollView( padding: EdgeInsets.symmetric(vertical: 16.h), child: Column( children: [ Padding( padding: EdgeInsets.only(bottom: 20.h), child: const GameStatusText(), ), GobangBoard(size: boardSize.toDouble()), SizedBox(height: 16.h), const GameActionBar(), ], ), ), ), ), ); }); } }