14-02
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
|
||||
|
||||
class ColorAddPage extends StatefulWidget {
|
||||
const ColorAddPage({super.key});
|
||||
@@ -22,31 +23,58 @@ class _ColorAddPageState extends State<ColorAddPage> {
|
||||
Widget build(BuildContext context) {
|
||||
String text = '# ${_color.value.toRadixString(16)}';
|
||||
return Scaffold(
|
||||
// appBar: AppBar(
|
||||
// title: Text('添加颜色'),
|
||||
// actions: [IconButton(onPressed: _selectColor, icon: Icon(Icons.check ))],
|
||||
// ),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0,vertical: 20),
|
||||
bottomNavigationBar: Container(
|
||||
margin: EdgeInsets.only(right:20,bottom: 20),
|
||||
// color: Colors.redAccent,
|
||||
child: Row(
|
||||
textDirection:TextDirection.rtl,
|
||||
children: [
|
||||
Expanded(child: Text(text,style: TextStyle(color: _color,fontSize: 24,letterSpacing: 4),)),
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 10),
|
||||
width: 40,
|
||||
height: 40,
|
||||
child: Icon(
|
||||
Icons.sell_outlined,
|
||||
color: Colors.white,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: _color,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
ElevatedButton(onPressed: (){
|
||||
Navigator.of(context).pop(_color);
|
||||
|
||||
}, child: Text('添加')),
|
||||
SizedBox(width: 12,),
|
||||
OutlinedButton(onPressed: (){
|
||||
Navigator.of(context).pop();
|
||||
}, child: Text('取消')),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Text(text,style: TextStyle(color: _color,fontSize: 24,letterSpacing: 4),)),
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 10),
|
||||
width: 40,
|
||||
height: 40,
|
||||
child: Icon(
|
||||
Icons.sell_outlined,
|
||||
color: Colors.white,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: _color,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
ColorPicker(
|
||||
colorPickerWidth:200,
|
||||
// enableAlpha: false,
|
||||
displayThumbColor:true,
|
||||
pickerColor: _color,
|
||||
paletteType: PaletteType.hueWheel,
|
||||
onColorChanged: changeColor,
|
||||
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -64,4 +92,11 @@ class _ColorAddPageState extends State<ColorAddPage> {
|
||||
void _selectColor() {
|
||||
Navigator.of(context).pop(_color);
|
||||
}
|
||||
|
||||
void changeColor(Color value) {
|
||||
_color = value;
|
||||
setState(() {
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:iroute/common/components/colors_panel.dart';
|
||||
import 'package:iroute/common/pages/stl_color_page.dart';
|
||||
import '../../app/navigation/app_router_delegate.dart';
|
||||
|
||||
// class HomePage extends StatelessWidget {
|
||||
// const HomePage({super.key});
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Scaffold(
|
||||
// body: const Center(child: Text('HomePage')));
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
class ColorPage extends StatefulWidget {
|
||||
const ColorPage({super.key});
|
||||
|
||||
@@ -45,11 +33,12 @@ class _ColorPageState extends State<ColorPage> {
|
||||
}
|
||||
|
||||
void _selectColor(Color color){
|
||||
// String value = color.value.toRadixString(16);
|
||||
String value = color.value.toRadixString(16);
|
||||
router.path = '/color/detail?color=$value';
|
||||
}
|
||||
|
||||
void _toAddPage() async {
|
||||
dynamic color = await router.changePathForResult('/color/add');
|
||||
Color? color = await router.changePathForResult('/color/add');
|
||||
if (color != null) {
|
||||
setState(() {
|
||||
_colors.add(color);
|
||||
|
||||
Reference in New Issue
Block a user