-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 添加主题颜色选择 # bug修复 - 修复图片加载的部分逻辑问题
- Loading branch information
Showing
14 changed files
with
365 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export './view/view.dart'; | ||
export './widgets/widgets.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import 'package:auto_route/annotations.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:zephyr/config/color_theme_types.dart'; | ||
import 'package:zephyr/main.dart'; | ||
import 'package:zephyr/page/theme_color/theme_color.dart'; | ||
|
||
@RoutePage() | ||
class ThemeColorPage extends StatefulWidget { | ||
const ThemeColorPage({super.key}); | ||
|
||
@override | ||
State<ThemeColorPage> createState() => _ThemeColorPageState(); | ||
} | ||
|
||
class _ThemeColorPageState extends State<ThemeColorPage> { | ||
Color _currentColor = globalSetting.seedColor; // 当前选择的颜色 | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text('主题颜色'), | ||
), | ||
body: SingleChildScrollView( | ||
child: Column( | ||
children: [ | ||
// 颜色选择器 | ||
ColorPickerPage( | ||
currentColor: _currentColor, | ||
onColorChanged: (color) { | ||
setState(() { | ||
_currentColor = color; // 更新颜色状态 | ||
}); | ||
_setThemeColor(color); // 更新全局主题颜色 | ||
}, | ||
), | ||
// 颜色块网格 | ||
Padding( | ||
padding: const EdgeInsets.all(16.0), | ||
child: Wrap( | ||
spacing: 16.0, // 水平间距 | ||
runSpacing: 16.0, // 垂直间距 | ||
children: colorThemeList.map((colorInfo) { | ||
return ColorThemeItem( | ||
colorInfo: colorInfo, | ||
currentColor: _currentColor, | ||
onColorSelected: (color) { | ||
setState(() { | ||
_currentColor = color; // 更新颜色状态 | ||
}); | ||
_setThemeColor(color); // 更新全局主题颜色 | ||
}, | ||
); | ||
}).toList(), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
|
||
void _setThemeColor(Color color) { | ||
globalSetting.setSeedColor(color); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export './theme_color_page.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:zephyr/config/global.dart'; | ||
|
||
import '../../../config/color_theme_types.dart'; | ||
|
||
class ColorThemeItem extends StatelessWidget { | ||
final ColorThemeInfo colorInfo; | ||
final Color currentColor; | ||
final Function(Color) onColorSelected; | ||
|
||
const ColorThemeItem({ | ||
super.key, | ||
required this.colorInfo, | ||
required this.currentColor, | ||
required this.onColorSelected, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SizedBox( | ||
width: screenWidth / 4 - 30, // 每个颜色块的宽度 | ||
child: Material( | ||
color: Colors.transparent, | ||
child: InkWell( | ||
onTap: () { | ||
onColorSelected(colorInfo.color); // 点击颜色块后回调 | ||
}, | ||
borderRadius: BorderRadius.circular(8), | ||
child: Column( | ||
children: [ | ||
Container( | ||
width: 60, | ||
height: 60, | ||
decoration: BoxDecoration( | ||
color: colorInfo.color, | ||
borderRadius: BorderRadius.circular(8), // 圆角 | ||
border: currentColor == colorInfo.color | ||
? Border.all(color: Colors.black, width: 2) // 选中状态 | ||
: null, | ||
), | ||
), | ||
SizedBox(height: 8), // 颜色块和文字的间距 | ||
Text( | ||
colorInfo.label, | ||
style: TextStyle(fontSize: 14), | ||
textAlign: TextAlign.center, | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_colorpicker/flutter_colorpicker.dart'; | ||
|
||
class ColorPickerPage extends StatelessWidget { | ||
final Color currentColor; | ||
final Function(Color) onColorChanged; | ||
|
||
const ColorPickerPage({ | ||
super.key, | ||
required this.currentColor, | ||
required this.onColorChanged, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Padding( | ||
padding: const EdgeInsets.all(16.0), | ||
child: Column( | ||
children: [ | ||
// 颜色选择器 | ||
HueRingPicker( | ||
pickerColor: currentColor, | ||
onColorChanged: onColorChanged, // 颜色变化时回调 | ||
displayThumbColor: true, // 是否显示拇指颜色 | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export './color_box.dart'; | ||
export './color_grid.dart'; | ||
export './ring_color_pick.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.