Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve UI and architecture #15

Merged
merged 26 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5acfa27
Fix deprecations
nohli Sep 17, 2021
ccbb692
Increase opacity to make letters above the sliders more readable
nohli Sep 17, 2021
20aad08
Improve color of app bar and button (especially in dark mode)
nohli Sep 17, 2021
31a2060
Make title of sliders look the same everywhere and move to own class
nohli Sep 17, 2021
3fd7d42
Create folder structure pickers for picker pages and widgets/ for sma…
nohli Sep 17, 2021
f4ef489
Simplify code
nohli Sep 17, 2021
c6be580
Make text and button height aligned
nohli Sep 17, 2021
bdb9335
Make SliderTitle Text widgets vertically aligned
nohli Sep 17, 2021
ba1806d
Improve opacity of SliderTitle's left text
nohli Sep 17, 2021
58695cc
Rename methods
nohli Sep 17, 2021
2d08498
Improve ui (padding, remove underline in portrait mode)
nohli Sep 17, 2021
5aa1677
Auto-update files
nohli Sep 17, 2021
6a3b8a3
Auto-format example/pubspec.yaml
nohli Sep 17, 2021
81988fa
Update version and changelog
nohli Sep 17, 2021
64ca48f
Update flutter_lints
nohli Sep 17, 2021
2ec62c1
Improve UI
nohli Sep 18, 2021
35ae4ba
Improve UI
nohli Sep 18, 2021
bf22af9
Improve UI
nohli Sep 18, 2021
45090f5
User BorderRadius.circular constructor
nohli Sep 19, 2021
6aaa9a6
Make padding on SliderTitle symmetric to better support RTL layout
nohli Sep 19, 2021
bc8ad85
Use SizedBox for whitespace
nohli Sep 19, 2021
651af5d
Use Container instead of Padding plus SizedBox and DecoratedBox
nohli Sep 19, 2021
4748241
Use BorderRadius.circular constructor
nohli Sep 19, 2021
21e062a
Refactor SliderTitle
nohli Sep 19, 2021
fd85a3d
Improve UI
nohli Sep 19, 2021
701d436
Add alignment and margin to Row instead of each of its children
nohli Sep 20, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [1.2.0]

* Update deprecated theme color (accentColor -> colorScheme.secondary)
* Improve UI
* Refactor folder structure

## [1.1.0]

* Fix ColorPicker not shown in landscape mode
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>9.0</string>
</dict>
</plist>
6 changes: 3 additions & 3 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -361,7 +361,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -408,7 +408,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
4 changes: 1 addition & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import 'package:flutter/widgets.dart';

import 'main_page.dart';

void main() async {
runApp(const MyApp());
}
void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
Expand Down
15 changes: 9 additions & 6 deletions example/lib/main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class _MainPageState extends State<MainPage> {

Widget buildDrawerHeader() {
return DrawerHeader(
decoration: BoxDecoration(color: theme.accentColor),
decoration: const BoxDecoration(color: Colors.blue),
AlexV525 marked this conversation as resolved.
Show resolved Hide resolved
child: Stack(
children: <Widget>[
// Avatar
Expand All @@ -196,10 +196,13 @@ class _MainPageState extends State<MainPage> {
backgroundColor: theme.cardColor,
backgroundImage: const AssetImage('packages/avatar.jpg'),
),
Container(height: 10.0),
const Text(
'淹死的鱼ysdy44',
style: TextStyle(color: Colors.white, fontSize: 18.0),
const SizedBox(height: 10.0),
const Padding(
padding: EdgeInsets.only(bottom: 8),
child: Text(
'淹死的鱼ysdy44',
style: TextStyle(color: Colors.white, fontSize: 18.0),
),
)
],
),
Expand All @@ -211,7 +214,7 @@ class _MainPageState extends State<MainPage> {
child: ElevatedButton(
onPressed: setTheme,
style: ElevatedButton.styleFrom(
primary: theme.accentColor,
primary: Colors.blue.shade400,
AlexV525 marked this conversation as resolved.
Show resolved Hide resolved
shape: const StadiumBorder(),
),
child: Text(
Expand Down
6 changes: 3 additions & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ dependencies:
path: ../

dev_dependencies:
flutter_lints: ^1.0.3
flutter_lints: ^1.0.4

flutter:
uses-material-design: true

assets:
- packages/avatar.jpg
- packages/avatar.jpg
22 changes: 11 additions & 11 deletions lib/flutter_hsvcolor_picker.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
library flutter_hsvcolor_picker;

export 'src/alpha_picker.dart';
export 'src/widgets/alpha_picker.dart';
export 'src/color_picker.dart';
export 'src/hex_picker.dart';
export 'src/hsv_picker.dart';
export 'src/palette_hue_picker.dart';
export 'src/palette_picker.dart';
export 'src/palette_saturation_picker.dart';
export 'src/palette_value_picker.dart';
export 'src/rgb_picker.dart';
export 'src/slider_picker.dart';
export 'src/swatches_picker.dart';
export 'src/wheel_picker.dart';
export 'src/widgets/hex_picker.dart';
export 'src/pickers/hsv_picker.dart';
export 'src/pickers/palette_hue_picker.dart';
export 'src/widgets/palette_picker.dart';
export 'src/pickers/palette_saturation_picker.dart';
export 'src/pickers/palette_value_picker.dart';
export 'src/pickers/rgb_picker.dart';
export 'src/widgets/slider_picker.dart';
export 'src/pickers/swatches_picker.dart';
export 'src/pickers/wheel_picker.dart';
74 changes: 35 additions & 39 deletions lib/src/color_picker.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import 'package:flutter/material.dart';

import 'alpha_picker.dart';
import 'hex_picker.dart';
import 'hsv_picker.dart';
import 'palette_hue_picker.dart';
import 'palette_saturation_picker.dart';
import 'palette_value_picker.dart';
import 'rgb_picker.dart';
import 'swatches_picker.dart';
import 'wheel_picker.dart';
import 'widgets/alpha_picker.dart';
import 'widgets/hex_picker.dart';
import 'pickers/hsv_picker.dart';
import 'pickers/palette_hue_picker.dart';
import 'pickers/palette_saturation_picker.dart';
import 'pickers/palette_value_picker.dart';
import 'pickers/rgb_picker.dart';
import 'pickers/swatches_picker.dart';
import 'pickers/wheel_picker.dart';

enum Picker {
swatches,
Expand Down Expand Up @@ -195,10 +195,10 @@ class _ColorPickerState extends State<ColorPicker> {
child: Text(
item.name,
style: _index == _pickers.indexOf(item)
? Theme.of(context)
.textTheme
.headline5
?.copyWith(fontSize: 18, color: Theme.of(context).accentColor)
? Theme.of(context).textTheme.headline5?.copyWith(
fontSize: 18,
color: Theme.of(context).colorScheme.secondary,
)
: Theme.of(context).textTheme.headline5?.copyWith(fontSize: 18),
),
),
Expand Down Expand Up @@ -244,18 +244,16 @@ class _ColorPickerState extends State<ColorPicker> {
);
}

Widget _buildDropdown() {
Widget _buildDropdownLandscapeMode() {
return SizedBox(
height: 38,
child: Material(
type: MaterialType.button,
color: Theme.of(context).cardColor,
shadowColor: Colors.black26,
elevation: 4.0,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(2.0),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(2.0),
),
child: DropdownButton<_IPicker>(
iconSize: 32.0,
Expand All @@ -272,27 +270,25 @@ class _ColorPickerState extends State<ColorPicker> {
);
}

Widget _buildDropdown2() {
return SizedBox(
Widget _buildDropdownPortraitMode() {
return Container(
margin: const EdgeInsets.symmetric(vertical: 6.0),
height: 38,
child: DecoratedBox(
decoration: BoxDecoration(
border: Border.all(color: Theme.of(context).dividerColor),
borderRadius: const BorderRadius.all(
Radius.circular(3.0),
),
),
child: DropdownButton<_IPicker>(
iconSize: 32.0,
isExpanded: true,
isDense: true,
style: Theme.of(context).textTheme.headline5?.copyWith(fontSize: 20),
value: _pickers[_index],
onChanged: (_IPicker? value) => super.setState(
() => _pickerOnChanged(value),
),
items: _pickers.map(_buildDropdownMenuItems).toList(),
decoration: BoxDecoration(
border: Border.all(color: Theme.of(context).dividerColor),
borderRadius: BorderRadius.circular(3.0),
),
child: DropdownButton<_IPicker>(
iconSize: 32.0,
isExpanded: true,
isDense: true,
style: Theme.of(context).textTheme.headline5?.copyWith(fontSize: 20),
value: _pickers[_index],
onChanged: (_IPicker? value) => super.setState(
() => _pickerOnChanged(value),
),
items: _pickers.map(_buildDropdownMenuItems).toList(),
underline: const SizedBox(),
),
);
}
Expand Down Expand Up @@ -321,7 +317,7 @@ class _ColorPickerState extends State<ColorPicker> {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
_buildHead(),
_buildDropdown2(),
_buildDropdownPortraitMode(),
_buildBody(),
_buildAlphaPicker(),
],
Expand All @@ -336,7 +332,7 @@ class _ColorPickerState extends State<ColorPicker> {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
_buildHead(),
_buildDropdown(),
_buildDropdownLandscapeMode(),
_buildAlphaPicker(),
],
),
Expand Down
35 changes: 5 additions & 30 deletions lib/src/hsv_picker.dart → lib/src/pickers/hsv_picker.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';

import 'slider_picker.dart';
import '../widgets/slider_picker.dart';
import '../widgets/slider_title.dart';

/// Three sliders for selections a color via:
/// Hue
Expand Down Expand Up @@ -55,39 +56,13 @@ class _HSVPickerState extends State<HSVPicker> {
color.withValue(1.0).toColor(),
];

Widget buildTitle(String title, String text) {
return SizedBox(
height: 34.0,
child: Row(
children: <Widget>[
Opacity(
opacity: 0.5,
child: Text(title, style: Theme.of(context).textTheme.headline6),
),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: Text(
text,
style: Theme.of(context)
.textTheme
.headline5
?.copyWith(fontSize: 18),
),
),
)
],
),
);
}

@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
// Hue
buildTitle('H', '${color.hue.toInt()}º'),
SliderTitle('H', '${color.hue.toInt()}º'),
SliderPicker(
value: color.hue,
max: 360.0,
Expand All @@ -96,15 +71,15 @@ class _HSVPickerState extends State<HSVPicker> {
),

// Saturation
buildTitle('S', '${(color.saturation * 100).toInt()}º'),
SliderTitle('S', '${(color.saturation * 100).toInt()}º'),
SliderPicker(
value: color.saturation,
onChanged: saturationOnChange,
colors: saturationColors,
),

// Value
buildTitle('L', '${(color.value * 100).toInt()}º'),
SliderTitle('L', '${(color.value * 100).toInt()}º'),
SliderPicker(
value: color.value,
onChanged: valueOnChange,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';

import 'palette_picker.dart';
import 'slider_picker.dart';
import '../widgets/palette_picker.dart';
import '../widgets/slider_picker.dart';

/// Color palette and color slider
class PaletteHuePicker extends StatefulWidget {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';

import 'palette_picker.dart';
import 'slider_picker.dart';
import '../widgets/palette_picker.dart';
import '../widgets/slider_picker.dart';

class PaletteSaturationPicker extends StatefulWidget {
const PaletteSaturationPicker({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';

import 'palette_picker.dart';
import 'slider_picker.dart';
import '../widgets/palette_picker.dart';
import '../widgets/slider_picker.dart';

class PaletteValuePicker extends StatefulWidget {
const PaletteValuePicker({
Expand Down
Loading