Skip to content

Commit

Permalink
Merge pull request #10 from Iconica-Development/feature/design
Browse files Browse the repository at this point in the history
feat: design changes
  • Loading branch information
Gorter-dev authored Jul 30, 2024
2 parents 5547a88 + 23cef42 commit 4935c13
Show file tree
Hide file tree
Showing 7 changed files with 567 additions and 371 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.5/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/sqflite-2.3.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/path_provider_android-2.2.4/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/shared_preferences_android-2.2.2/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/sqflite-2.3.3/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.5/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/sqflite-2.3.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.2/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"path_provider_windows","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.3.2/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"shared_preferences_web","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/shared_preferences_web-2.3.0/","dependencies":[]}]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"sqflite","dependencies":[]}],"date_created":"2024-05-30 12:57:48.650237","version":"3.19.5"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.5/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/sqflite-2.3.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/path_provider_android-2.2.4/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/shared_preferences_android-2.2.2/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/sqflite-2.3.3/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.5/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/sqflite-2.3.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.2/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"path_provider_windows","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.3.2/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"shared_preferences_web","path":"/Users/mikedoornenbal/.pub-cache/hosted/pub.dev/shared_preferences_web-2.3.0/","dependencies":[]}]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"sqflite","dependencies":[]}],"date_created":"2024-07-16 09:37:36.850324","version":"3.22.2"}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 4.0.0

* Added theme to text components
* Changed default `ControlWrapper` design


## 3.0.0

* added onChange callback to the settings widgets
Expand Down
191 changes: 95 additions & 96 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_settings/flutter_settings.dart';

void main() {
Expand Down Expand Up @@ -48,115 +47,90 @@ class Settings extends StatelessWidget {

@override
Widget build(BuildContext context) {
var theme = Theme.of(context);
return SafeArea(
child: Scaffold(
body: Center(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: DecoratedBox(
decoration: BoxDecoration(border: Border.all()),
child: DeviceSettingsPage(
child: DeviceSettingsPage(
settings: [
Control.group(
title: 'SUBPAGE',
settings: [

Control.dropDown(
key: 'dropdown',
items: ['Item1', 'Item2', 'Item3'],
title: 'Dropdown',
suffixIcon: const Icon(Icons.settings),
Control.page(
controls: pages,
title: 'Item 1',
description: "This is a description",
preficIcon: Icon(
Icons.person_outline,
size: 32,
color: theme.colorScheme.primary,
),
),
Control.radio(
key: 'dropdown',
items: [
const RadioItem<String>(
value: 'Item1',
child: Text('item1'),
),
const RadioItem<String>(
value: 'Item2',
child: Text('item2'),
),
const RadioItem<String>(
value: 'Item3',
child: Text('item3'),
),
],
title: 'Dropdown',
Control.page(
controls: pages,
title: 'Setting name',
description: "This is a description",
preficIcon: Icon(
Icons.person_outline,
size: 32,
color: theme.colorScheme.primary,
),
),
Control.number(
key: 'number',
title: 'Number',
Control.page(
controls: pages,
title: 'Setting name',
preficIcon: Icon(
Icons.person_outline,
size: 32,
color: theme.colorScheme.primary,
),
),
Control.textField(
key: 'textfield',
title: 'Textfield',
suffixIcon: const Icon(Icons.settings),
validator: (value) {
if (value == null || value.isEmpty) {
return "Field can't be empty";
}

return null;
},
],
),
Control.group(
title: 'TOGGLE',
settings: [
Control.toggle(
value: false,
key: 'Settingsname',
title: 'Setting name',
description: "This is a description",
),
Control.textField(
key: 'numberfield',
title: 'Numberfield',
suffixIcon: const Icon(Icons.settings),
validator: (value) {
if (value == null || value.isEmpty) {
return "Field can't be empty";
}

return null;
},
keyboardType: TextInputType.number,
formatInputs: [FilteringTextInputFormatter.digitsOnly],
Control.toggle(
value: true,
key: 'Settingsname1',
title: 'Setting name',
),
Control.page(
controls: [
Control.toggle(
key: 'toggle',
title: 'Toggle',
),
Control.checkBox(
key: 'checkbox',
title: 'Checkbox',
),
],
title: 'Bool page',
],
),
Control.group(
title: 'CHECKBOX',
settings: [
Control.checkBox(
value: false,
key: 'Settingsnam2',
title: 'Setting name',
prefixIcon: Icon(
Icons.person_outline,
size: 32,
color: theme.colorScheme.primary,
),
),
Control.group(
title: 'Group title',
settings: [
Control.date(
key: 'date',
min: DateTime.now().subtract(
const Duration(days: 365),
),
max: DateTime.now().add(
const Duration(days: 365),
),
value: DateTime.now(),
title: 'Date',
suffixIcon: const Icon(Icons.settings),
),
Control.time(
key: 'time',
value: TimeOfDay.now(),
title: 'Time',
suffixIcon: const Icon(Icons.settings),
),
Control.dateRange(
key: 'dateRange',
title: 'Date range',
suffixIcon: const Icon(Icons.settings),
),
],
Control.checkBox(
value: true,
key: 'Settingsname3',
title: 'Setting name',
prefixIcon: Icon(
Icons.person_outline,
size: 32,
color: theme.colorScheme.primary,
),
description: "This is a description",
),
],
),
),
],
),
),
),
Expand All @@ -170,3 +144,28 @@ class Settings extends StatelessWidget {
);
}
}

List<Control> pages = [
Control.toggle(
key: 'settingsName5',
title: 'Setting name',
description: 'Description',
),
Control.group(
title: 'SECTION',
settings: [
Control.checkBox(
value: false,
key: 'Settingsnam8',
title: 'Setting name',
description: "This is a description",
),
Control.checkBox(
value: true,
key: 'Settingsname7',
title: 'Setting name',
description: "This is a description",
),
],
),
];
43 changes: 41 additions & 2 deletions lib/src/ui/control.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ class Control extends ChangeNotifier {
this.maxLines,
this.description,
this.boxDecoration,
this.prefixIcon,
this.partOfGroup = false,
this.isLastSettingInGroup = false,
this.hintText,
this.initialValue,
});

factory Control.custom({
Expand All @@ -68,13 +73,15 @@ class Control extends ChangeNotifier {
required List<Control> controls,
required String title,
String? description,
Icon? preficIcon,
}) =>
Control(
type: ControlType.page,
key: 'page_$title',
title: title,
settings: controls,
description: description,
prefixIcon: preficIcon,
);

factory Control.radio({
Expand All @@ -83,13 +90,15 @@ class Control extends ChangeNotifier {
String? title,
String? selected,
void Function(dynamic)? onChange,
String? description,
}) =>
Control(
value: {'items': items, 'selected': selected},
type: ControlType.radio,
title: title,
onChange: onChange,
key: key,
description: description,
);

factory Control.dropDown({
Expand All @@ -101,6 +110,7 @@ class Control extends ChangeNotifier {
Widget? suffixIcon,
String? Function(String?)? validator,
String? description,
String? hintText,
}) {
if (selected != null) {
assert(selected < items.length, 'Selected exceeds item length');
Expand All @@ -117,6 +127,7 @@ class Control extends ChangeNotifier {
suffixIcon: suffixIcon,
validator: validator,
description: description,
hintText: hintText,
);
}

Expand All @@ -126,6 +137,8 @@ class Control extends ChangeNotifier {
void Function(Map<String, dynamic>)? onChange,
bool? value,
String? description,
Icon? prefixIcon,
bool partOfGroup = false,
}) =>
Control(
title: title ?? '',
Expand All @@ -136,13 +149,18 @@ class Control extends ChangeNotifier {
key: key,
type: ControlType.toggle,
description: description,
prefixIcon: prefixIcon,
partOfGroup: partOfGroup,
);

factory Control.checkBox({
required String key,
String? title,
void Function(dynamic)? onChange,
bool? value,
Icon? prefixIcon,
String? description,
bool partOfGroup = false,
}) =>
Control(
title: title ?? '',
Expand All @@ -152,6 +170,9 @@ class Control extends ChangeNotifier {
},
key: key,
type: ControlType.checkBox,
prefixIcon: prefixIcon,
description: description,
partOfGroup: partOfGroup,
);

factory Control.number({
Expand Down Expand Up @@ -275,7 +296,6 @@ class Control extends ChangeNotifier {
String? title,
Widget? content,
void Function(dynamic)? onChange,
String? defaultValue,
TextInputType? keyboardType,
FormFieldValidator<String>? validator,
bool isRequired = false,
Expand All @@ -284,6 +304,8 @@ class Control extends ChangeNotifier {
InputDecoration? decoration,
int? maxLines,
String? description,
String? hintText,
String? initialValue,
}) =>
Control(
title: title ?? '',
Expand All @@ -293,7 +315,7 @@ class Control extends ChangeNotifier {
onChange: (value) {
onChange?.call(value);
},
value: defaultValue,
initialValue: initialValue,
keyboardType: keyboardType,
validator: validator,
isRequired: isRequired,
Expand All @@ -302,6 +324,7 @@ class Control extends ChangeNotifier {
suffixIcon: suffixIcon,
maxLines: maxLines,
description: description,
hintText: hintText,
);

/// The value is the defaultvalue along with the items or options depending on
Expand Down Expand Up @@ -368,8 +391,24 @@ class Control extends ChangeNotifier {
/// The description is shown below the title
String? description;

/// The decoration of the input
BoxDecoration? boxDecoration;

/// The icon that is shown on the left side of the input
Icon? prefixIcon;

/// If the Control is part of a group
bool partOfGroup;

/// If the Control is the last setting in a group
bool isLastSettingInGroup;

/// The hint text that is shown in the input field
String? hintText;

/// The initial value of the input field
String? initialValue;

void change(value) {
onChange?.call(value);
notifyListeners();
Expand Down
Loading

0 comments on commit 4935c13

Please sign in to comment.