|
@@ -3,15 +3,16 @@ import 'dart:math';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:gobang/ai/Ai.dart';
|
|
import 'package:gobang/ai/Ai.dart';
|
|
-import 'package:gobang/factory/ThemeFactory.dart';
|
|
|
|
import 'package:gobang/flyweight/Chess.dart';
|
|
import 'package:gobang/flyweight/Chess.dart';
|
|
import 'package:gobang/memorandum/Checkerboard.dart';
|
|
import 'package:gobang/memorandum/Checkerboard.dart';
|
|
|
|
+import 'package:gobang/model/BlackTheme.dart';
|
|
|
|
+import 'package:gobang/model/BlueTheme.dart';
|
|
|
|
+import 'package:gobang/model/base_theme.dart';
|
|
import 'package:gobang/utils/TipsDialog.dart';
|
|
import 'package:gobang/utils/TipsDialog.dart';
|
|
import 'package:gobang/viewModel/GameViewModel.dart';
|
|
import 'package:gobang/viewModel/GameViewModel.dart';
|
|
|
|
|
|
import '../bridge/CircleShape.dart';
|
|
import '../bridge/CircleShape.dart';
|
|
-import '../factory/BlackThemeFactory.dart';
|
|
|
|
-import '../factory/BlueThemeFactory.dart';
|
|
|
|
|
|
+
|
|
import '../flyweight/Position.dart';
|
|
import '../flyweight/Position.dart';
|
|
|
|
|
|
var width = 0.0;
|
|
var width = 0.0;
|
|
@@ -20,12 +21,14 @@ var width = 0.0;
|
|
/// Time : 02/20/2024 Tuesday
|
|
/// Time : 02/20/2024 Tuesday
|
|
/// Author : liuyuqi.gov@msn.cn
|
|
/// Author : liuyuqi.gov@msn.cn
|
|
class HomePage extends StatefulWidget {
|
|
class HomePage extends StatefulWidget {
|
|
|
|
+ const HomePage({Key? key}) : super(key: key);
|
|
|
|
+
|
|
@override
|
|
@override
|
|
State<StatefulWidget> createState() => HomePageState();
|
|
State<StatefulWidget> createState() => HomePageState();
|
|
}
|
|
}
|
|
|
|
|
|
class HomePageState extends State<HomePage> {
|
|
class HomePageState extends State<HomePage> {
|
|
- ThemeFactory? _themeFactory;
|
|
|
|
|
|
+ BaseTheme? _theme;
|
|
GameViewModel _viewModel = GameViewModel.getInstance();
|
|
GameViewModel _viewModel = GameViewModel.getInstance();
|
|
Checkerboard _originator = Checkerboard.getInstance();
|
|
Checkerboard _originator = Checkerboard.getInstance();
|
|
Icon lightOn = Icon(Icons.lightbulb, color: Colors.amberAccent);
|
|
Icon lightOn = Icon(Icons.lightbulb, color: Colors.amberAccent);
|
|
@@ -37,7 +40,7 @@ class HomePageState extends State<HomePage> {
|
|
@override
|
|
@override
|
|
void initState() {
|
|
void initState() {
|
|
currentLight = lightOn;
|
|
currentLight = lightOn;
|
|
- _themeFactory = BlueThemeFactory();
|
|
|
|
|
|
+ _theme = BlueTheme();
|
|
currentShape = circle;
|
|
currentShape = circle;
|
|
super.initState();
|
|
super.initState();
|
|
}
|
|
}
|
|
@@ -49,18 +52,18 @@ class HomePageState extends State<HomePage> {
|
|
return Scaffold(
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
appBar: AppBar(
|
|
elevation: 0,
|
|
elevation: 0,
|
|
- backgroundColor: _themeFactory!.getTheme().getThemeColor(),
|
|
|
|
|
|
+ backgroundColor: _theme!.getThemeColor(),
|
|
title: Text("南瓜五子棋"),
|
|
title: Text("南瓜五子棋"),
|
|
actions: [
|
|
actions: [
|
|
IconButton(
|
|
IconButton(
|
|
onPressed: () {
|
|
onPressed: () {
|
|
setState(() {
|
|
setState(() {
|
|
- if (_themeFactory is BlackThemeFactory) {
|
|
|
|
|
|
+ if (_theme is BlackTheme) {
|
|
currentLight = lightOn;
|
|
currentLight = lightOn;
|
|
- _themeFactory = BlueThemeFactory();
|
|
|
|
|
|
+ _theme = BlueTheme();
|
|
} else {
|
|
} else {
|
|
currentLight = lightOff;
|
|
currentLight = lightOff;
|
|
- _themeFactory = BlackThemeFactory();
|
|
|
|
|
|
+ _theme = BlackTheme();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
@@ -82,7 +85,7 @@ class HomePageState extends State<HomePage> {
|
|
decoration: BoxDecoration(
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
gradient: LinearGradient(
|
|
colors: [
|
|
colors: [
|
|
- _themeFactory!.getTheme().getThemeColor(),
|
|
|
|
|
|
+ _theme!.getThemeColor(),
|
|
Colors.white,
|
|
Colors.white,
|
|
],
|
|
],
|
|
stops: [
|
|
stops: [
|