From dcd05b53b482f4b3a95916413164a901749caf81 Mon Sep 17 00:00:00 2001 From: Leandro Date: Mon, 20 May 2024 00:13:52 +0200 Subject: [PATCH] Added color picker --- lib/screens/add_wool_modal.dart | 19 ++++++++++++++++++- lib/screens/wool.dart | 1 + lib/widgets/modal_wrapper.dart | 17 +++++++++++++---- pubspec.lock | 8 ++++++++ pubspec.yaml | 2 ++ 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/lib/screens/add_wool_modal.dart b/lib/screens/add_wool_modal.dart index 7ab24fd..d203934 100644 --- a/lib/screens/add_wool_modal.dart +++ b/lib/screens/add_wool_modal.dart @@ -1,8 +1,15 @@ import 'package:flutter/material.dart'; +import 'package:flutter_colorpicker/flutter_colorpicker.dart'; import 'package:temperaturdecke/widgets/modal_wrapper.dart'; class AddWoolModal extends StatelessWidget { - const AddWoolModal({super.key}); + AddWoolModal({super.key}); + + String selectedColor = "#FFFFFF"; + + void setSelectedColor(Color color) { + selectedColor = colorToHex(color); + } @override Widget build(BuildContext context) { @@ -11,6 +18,16 @@ class AddWoolModal extends StatelessWidget { children: [ TextField(), TextField(), + SizedBox( + height: 25, + ), + ColorPicker( + displayThumbColor: false, + colorPickerWidth: 200, + enableAlpha: false, + pickerColor: Colors.black, + onColorChanged: setSelectedColor, + ) ], ), title: "Wolle hinzufügen", diff --git a/lib/screens/wool.dart b/lib/screens/wool.dart index 7a45422..53195a5 100644 --- a/lib/screens/wool.dart +++ b/lib/screens/wool.dart @@ -25,6 +25,7 @@ class WoolScreen extends StatelessWidget { floatingActionButton: FloatingActionButton( onPressed: () { showModalBottomSheet( + isScrollControlled: true, showDragHandle: true, context: context, builder: (context) { diff --git a/lib/widgets/modal_wrapper.dart b/lib/widgets/modal_wrapper.dart index e1216b9..6cbcc56 100644 --- a/lib/widgets/modal_wrapper.dart +++ b/lib/widgets/modal_wrapper.dart @@ -8,9 +8,14 @@ class ModalWrapper extends StatelessWidget { @override Widget build(BuildContext context) { return ClipRRect( - borderRadius: BorderRadius.vertical(top: Radius.circular(20)), - child: SizedBox( - width: 750, + borderRadius: BorderRadius.vertical( + top: Radius.circular(20), + ), + child: Wrap( + children: [ + SizedBox( + width: 500, + height: MediaQuery.of(context).size.height - 100, child: Padding( padding: EdgeInsets.symmetric(horizontal: 25, vertical: 10), child: Column( @@ -24,6 +29,10 @@ class ModalWrapper extends StatelessWidget { child ], ), - ))); + ), + ), + ], + ), + ); } } diff --git a/pubspec.lock b/pubspec.lock index 5dc1f32..26d6386 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -270,6 +270,14 @@ packages: description: flutter source: sdk 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: dependency: "direct dev" description: diff --git a/pubspec.yaml b/pubspec.yaml index ce258ab..cc4d040 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -33,6 +33,8 @@ dependencies: blobs: + flutter_colorpicker: + hexcolor: dynamic_color: