Skip to content

Commit

Permalink
Support analysis toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
calcitem committed Apr 27, 2024
1 parent bd69e55 commit 598ff6e
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class ColorSettings {
this.mainToolbarIconColor = UIColors.cocoaBean60,
this.navigationToolbarBackgroundColor = UIColors.burlyWood,
this.navigationToolbarIconColor = UIColors.cocoaBean60,
this.analysisToolbarBackgroundColor = UIColors.burlyWood,
this.analysisToolbarIconColor = UIColors.cocoaBean60,
});

/// Encodes a Json style map Color a [ColorSettings] object
Expand Down Expand Up @@ -162,6 +164,20 @@ class ColorSettings {
@HiveField(14)
final Color navigationToolbarIconColor;

@JsonKey(
fromJson: ColorAdapter.colorFromJson,
toJson: ColorAdapter.colorToJson,
)
@HiveField(15)
final Color analysisToolbarBackgroundColor;

@JsonKey(
fromJson: ColorAdapter.colorFromJson,
toJson: ColorAdapter.colorToJson,
)
@HiveField(16)
final Color analysisToolbarIconColor;

/// Decodes a Json from a [ColorSettings] object
Map<String, dynamic> toJson() => _$ColorSettingsToJson(this);
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class DisplaySettings {
this.isPositionalAdvantageIndicatorShown = false,
this.backgroundImagePath = '',
this.isNumbersOnPiecesShown = false,
this.isAnalysisToolbarShown = false,
});

/// Encodes a Json style map into a [DisplaySettings] object
Expand Down Expand Up @@ -149,6 +150,9 @@ class DisplaySettings {
@HiveField(21, defaultValue: false)
final bool isNumbersOnPiecesShown;

@HiveField(22, defaultValue: false)
final bool isAnalysisToolbarShown;

/// Decodes a Json from a [DisplaySettings] object
Map<String, dynamic> toJson() => _$DisplaySettingsToJson(this);
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ class AppearanceSettingsPage extends StatelessWidget {
AppTheme.colorThemes[theme]!.navigationToolbarBackgroundColor,
navigationToolbarIconColor:
AppTheme.colorThemes[theme]!.navigationToolbarIconColor,
analysisToolbarBackgroundColor:
AppTheme.colorThemes[theme]!.analysisToolbarBackgroundColor,
analysisToolbarIconColor:
AppTheme.colorThemes[theme]!.analysisToolbarIconColor,
);
}

Expand Down Expand Up @@ -264,6 +268,20 @@ class AppearanceSettingsPage extends StatelessWidget {
navigationToolbarIconColor: val,
),
),
SettingsListTile.color(
titleString: S.of(context).analysisToolbarBackgroundColor,
value: DB().colorSettings.analysisToolbarBackgroundColor,
onChanged: (Color val) => DB().colorSettings = colorSettings.copyWith(
analysisToolbarBackgroundColor: val,
),
),
SettingsListTile.color(
titleString: S.of(context).analysisToolbarIconColor,
value: DB().colorSettings.analysisToolbarIconColor,
onChanged: (Color val) => DB().colorSettings = colorSettings.copyWith(
analysisToolbarIconColor: val,
),
),
],
);
}
Expand Down Expand Up @@ -337,6 +355,12 @@ class AppearanceSettingsPage extends StatelessWidget {
displaySettings.copyWith(isHistoryNavigationToolbarShown: val),
titleString: S.of(context).isHistoryNavigationToolbarShown,
),
SettingsListTile.switchTile(
value: displaySettings.isAnalysisToolbarShown,
onChanged: (bool val) => DB().displaySettings =
displaySettings.copyWith(isAnalysisToolbarShown: val),
titleString: S.of(context).isAnalysisToolbarShown,
),
SettingsListTile.switchTile(
value: displaySettings.isPositionalAdvantageIndicatorShown,
onChanged: (bool val) => DB().displaySettings = displaySettings
Expand Down
24 changes: 24 additions & 0 deletions src/ui/flutter_app/lib/game_page/widgets/game_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ class GamePage extends StatelessWidget {
.displaySettings
.isHistoryNavigationToolbarShown) {
toolbarHeight *= 2;
} else if (DB().displaySettings.isAnalysisToolbarShown) {
toolbarHeight *= 3;
}

// Constraints of the game board but applied to the entire child
Expand Down Expand Up @@ -312,6 +314,21 @@ class _GameState extends State<_Game> {
];
}

List<Widget> analysisToolbarItems(BuildContext context) {
final ToolbarItem captureBoardImageButton = ToolbarItem(
child: Icon(
FluentIcons.arrow_previous_24_regular,
// TODO
semanticLabel: S.of(context).takeBackAll,
),
onPressed: () => HistoryNavigator.takeBackAll(context, pop: false),
);

return <Widget>[
Expanded(child: captureBoardImageButton),
];
}

String getPiecesText(int count) {
String ret = "";
for (int i = 0; i < count; i++) {
Expand Down Expand Up @@ -503,6 +520,13 @@ class _GameState extends State<_Game> {
itemColor: DB().colorSettings.navigationToolbarIconColor,
children: historyNavToolbarItems(context),
),
if (DB().displaySettings.isAnalysisToolbarShown)
GamePageToolbar(
backgroundColor:
DB().colorSettings.analysisToolbarBackgroundColor,
itemColor: DB().colorSettings.analysisToolbarIconColor,
children: analysisToolbarItems(context),
),
if (GameController().gameInstance.gameMode !=
GameMode.setupPosition)
GamePageToolbar(
Expand Down
8 changes: 7 additions & 1 deletion src/ui/flutter_app/lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1503,5 +1503,11 @@
"youCanEnableScreenReaderSupport": "You can enable the Screen reader support switch in the Accessibility configuration in General Settings.",
"@youCanEnableScreenReaderSupport": {},
"showNumbersOnPieces": "Show numbers on pieces",
"@showNumbersOnPieces": {}
"@showNumbersOnPieces": {},
"isAnalysisToolbarShown": "Show analysis toolbar",
"@isAnalysisToolbarShown": {},
"analysisToolbarBackgroundColor": "Analysis toolbar background color",
"@analysisToolbarBackgroundColor": {},
"analysisToolbarIconColor": "Analysis toolbar icon color",
"@analysisToolbarIconColor": {}
}
30 changes: 30 additions & 0 deletions src/ui/flutter_app/lib/shared/themes/app_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ class AppTheme {
mainToolbarIconColor: UIColors.tahitiGold60,
navigationToolbarBackgroundColor: Colors.black,
navigationToolbarIconColor: UIColors.tahitiGold60,
analysisToolbarBackgroundColor: Colors.black,
analysisToolbarIconColor: UIColors.tahitiGold60,
),
ColorTheme.monochrome: ColorSettings(
boardLineColor: Colors.black,
Expand All @@ -393,6 +395,8 @@ class AppTheme {
mainToolbarIconColor: Colors.black,
navigationToolbarBackgroundColor: Colors.white,
navigationToolbarIconColor: Colors.black,
analysisToolbarBackgroundColor: Colors.white,
analysisToolbarIconColor: Colors.black,
),
ColorTheme.goldenJade: ColorSettings(
boardBackgroundColor: Color(0xFFC89B42), // golden
Expand All @@ -410,6 +414,8 @@ class AppTheme {
mainToolbarIconColor: Color(0xFFA4A293), // warm gray
navigationToolbarBackgroundColor: Color(0xFFE9E7D7), // light beige
navigationToolbarIconColor: Color(0xFFA4A293), // warm gray
analysisToolbarBackgroundColor: Color(0xFFE9E7D7), // light beige
analysisToolbarIconColor: Color(0xFFA4A293), // warm gray
),
ColorTheme.forestWood: ColorSettings(
boardBackgroundColor: Color(0xFFC19A6B), // wood brown
Expand All @@ -427,6 +433,8 @@ class AppTheme {
mainToolbarIconColor: Color(0xFFA4A293), // warm gray
navigationToolbarBackgroundColor: Color(0xFF8B5A2B), // dark wood brown
navigationToolbarIconColor: Color(0xFFA4A293), // warm gray
analysisToolbarBackgroundColor: Color(0xFF8B5A2B), // dark wood brown
analysisToolbarIconColor: Color(0xFFA4A293), // warm gray
),
ColorTheme.greenMeadow: ColorSettings(
boardBackgroundColor: Color(0xFF9ACD32), // yellow-green
Expand All @@ -444,6 +452,8 @@ class AppTheme {
mainToolbarIconColor: Color(0xFFA4A293), // warm gray
navigationToolbarBackgroundColor: Color(0xFF006400), // dark green
navigationToolbarIconColor: Color(0xFFA4A293), // warm gray
analysisToolbarBackgroundColor: Color(0xFF006400), // dark green
analysisToolbarIconColor: Color(0xFFA4A293), // warm gray
),
ColorTheme.stonyPath: ColorSettings(
boardBackgroundColor: Color(0xFFC0C0C0), // silver
Expand All @@ -460,6 +470,8 @@ class AppTheme {
mainToolbarIconColor: Color(0xFFA4A293), // warm gray
navigationToolbarBackgroundColor: Color(0xFF808080), // gray
navigationToolbarIconColor: Color(0xFFA4A293), // warm gray
analysisToolbarBackgroundColor: Color(0xFF808080), // gray
analysisToolbarIconColor: Color(0xFFA4A293), // warm gray
),
ColorTheme.midnightBlue: ColorSettings(
boardBackgroundColor: Color(0xFF162447), // midnight blue
Expand All @@ -477,6 +489,8 @@ class AppTheme {
mainToolbarIconColor: Color(0xFFA4A293), // warm gray
navigationToolbarBackgroundColor: Color(0xFF1f4068), // deep blue
navigationToolbarIconColor: Color(0xFFA4A293), // warm gray
analysisToolbarBackgroundColor: Color(0xFF1f4068), // deep blue
analysisToolbarIconColor: Color(0xFFA4A293), // warm gray
),
ColorTheme.greenForest: ColorSettings(
boardBackgroundColor: Color(0xFFa9eec2), // light green
Expand All @@ -493,6 +507,8 @@ class AppTheme {
mainToolbarIconColor: Color(0xFFA4A293), // warm gray
navigationToolbarBackgroundColor: Color(0xFF4DAA4C), // forest green
navigationToolbarIconColor: Color(0xFFA4A293), // warm gray
analysisToolbarBackgroundColor: Color(0xFF4DAA4C), // forest green
analysisToolbarIconColor: Color(0xFFA4A293), // warm gray
),
ColorTheme.pastelPink: ColorSettings(
boardBackgroundColor: Color(0xFFf7bacf), // pastel pink
Expand All @@ -509,6 +525,8 @@ class AppTheme {
mainToolbarIconColor: Color(0xFFA4A293), // warm gray
navigationToolbarBackgroundColor: Color(0xFFefc3e6), // light pink
navigationToolbarIconColor: Color(0xFFA4A293), // warm gray
analysisToolbarBackgroundColor: Color(0xFFefc3e6), // light pink
analysisToolbarIconColor: Color(0xFFA4A293), // warm gray
),
ColorTheme.turquoiseSea: ColorSettings(
boardBackgroundColor: Color(0xFFc9ada1), // beige
Expand All @@ -525,6 +543,8 @@ class AppTheme {
mainToolbarIconColor: Color(0xFFA4A293), // warm gray
navigationToolbarBackgroundColor: Color(0xFF1f7a8c), // dark turquoise
navigationToolbarIconColor: Color(0xFFA4A293), // warm gray
analysisToolbarBackgroundColor: Color(0xFF1f7a8c), // dark turquoise
analysisToolbarIconColor: Color(0xFFA4A293), // warm gray
),
ColorTheme.violetDream: ColorSettings(
boardBackgroundColor: Color(0xFF8b77a9), // violet
Expand All @@ -542,6 +562,8 @@ class AppTheme {
mainToolbarIconColor: Color(0xFFA4A293), // warm gray
navigationToolbarBackgroundColor: Color(0xFF583d72), // dark violet
navigationToolbarIconColor: Color(0xFFA4A293), // warm gray
analysisToolbarBackgroundColor: Color(0xFF583d72), // dark violet
analysisToolbarIconColor: Color(0xFFA4A293), // warm gray
),
ColorTheme.mintChocolate: ColorSettings(
boardBackgroundColor: Color(0xFFA1E8AF), // mint
Expand All @@ -559,6 +581,8 @@ class AppTheme {
mainToolbarIconColor: Color(0xFFA4A293), // warm gray
navigationToolbarBackgroundColor: Color(0xFF0B3D0B), // dark green
navigationToolbarIconColor: Color(0xFFA4A293), // warm gray
analysisToolbarBackgroundColor: Color(0xFF0B3D0B), // dark green
analysisToolbarIconColor: Color(0xFFA4A293), // warm gray
),
ColorTheme.skyBlue: ColorSettings(
boardBackgroundColor: Color(0xFFD0E1F9), // light sky blue
Expand All @@ -575,6 +599,8 @@ class AppTheme {
mainToolbarIconColor: Color(0xFFA4A293), // warm gray
navigationToolbarBackgroundColor: Color(0xFF4B89AC), // steel blue
navigationToolbarIconColor: Color(0xFFA4A293), // warm gray
analysisToolbarBackgroundColor: Color(0xFF4B89AC), // steel blue
analysisToolbarIconColor: Color(0xFFA4A293), // warm gray
),
ColorTheme.playfulGarden: ColorSettings(
boardBackgroundColor: Color(0xFFFBE9A6), // light yellow
Expand All @@ -591,6 +617,8 @@ class AppTheme {
mainToolbarIconColor: Color(0xFFA4A293), // warm gray
navigationToolbarBackgroundColor: Color(0xFFB8DCAC), // light green
navigationToolbarIconColor: Color(0xFFA4A293), // warm gray
analysisToolbarBackgroundColor: Color(0xFFB8DCAC), // light green
analysisToolbarIconColor: Color(0xFFA4A293), // warm gray
),
ColorTheme.darkMystery: ColorSettings(
boardBackgroundColor: Color(0xFF5C5C5C), // dark silver
Expand All @@ -609,6 +637,8 @@ class AppTheme {
mainToolbarIconColor: Color(0xFFA4A293), // warm gray
navigationToolbarBackgroundColor: Color(0xFF0F0F0F), // almost black
navigationToolbarIconColor: Color(0xFFA4A293), // warm gray
analysisToolbarBackgroundColor: Color(0xFF0F0F0F), // almost black
analysisToolbarIconColor: Color(0xFFA4A293), // warm gray
),
};
}

0 comments on commit 598ff6e

Please sign in to comment.