Added color picker

This commit is contained in:
Leandro 2024-05-20 00:13:52 +02:00
parent 22aca9618e
commit dcd05b53b4
5 changed files with 42 additions and 5 deletions

View file

@ -1,8 +1,15 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
import 'package:temperaturdecke/widgets/modal_wrapper.dart'; import 'package:temperaturdecke/widgets/modal_wrapper.dart';
class AddWoolModal extends StatelessWidget { class AddWoolModal extends StatelessWidget {
const AddWoolModal({super.key}); AddWoolModal({super.key});
String selectedColor = "#FFFFFF";
void setSelectedColor(Color color) {
selectedColor = colorToHex(color);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -11,6 +18,16 @@ class AddWoolModal extends StatelessWidget {
children: [ children: [
TextField(), TextField(),
TextField(), TextField(),
SizedBox(
height: 25,
),
ColorPicker(
displayThumbColor: false,
colorPickerWidth: 200,
enableAlpha: false,
pickerColor: Colors.black,
onColorChanged: setSelectedColor,
)
], ],
), ),
title: "Wolle hinzufügen", title: "Wolle hinzufügen",

View file

@ -25,6 +25,7 @@ class WoolScreen extends StatelessWidget {
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
onPressed: () { onPressed: () {
showModalBottomSheet( showModalBottomSheet(
isScrollControlled: true,
showDragHandle: true, showDragHandle: true,
context: context, context: context,
builder: (context) { builder: (context) {

View file

@ -8,9 +8,14 @@ class ModalWrapper extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ClipRRect( return ClipRRect(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)), borderRadius: BorderRadius.vertical(
child: SizedBox( top: Radius.circular(20),
width: 750, ),
child: Wrap(
children: [
SizedBox(
width: 500,
height: MediaQuery.of(context).size.height - 100,
child: Padding( child: Padding(
padding: EdgeInsets.symmetric(horizontal: 25, vertical: 10), padding: EdgeInsets.symmetric(horizontal: 25, vertical: 10),
child: Column( child: Column(
@ -24,6 +29,10 @@ class ModalWrapper extends StatelessWidget {
child child
], ],
), ),
))); ),
),
],
),
);
} }
} }

View file

@ -270,6 +270,14 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_colorpicker:
dependency: "direct main"
description:
name: flutter_colorpicker
sha256: "969de5f6f9e2a570ac660fb7b501551451ea2a1ab9e2097e89475f60e07816ea"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
flutter_lints: flutter_lints:
dependency: "direct dev" dependency: "direct dev"
description: description:

View file

@ -33,6 +33,8 @@ dependencies:
blobs: blobs:
flutter_colorpicker:
hexcolor: hexcolor:
dynamic_color: dynamic_color: