Skip to content

Commit

Permalink
Merge pull request #63 from Frezyx/dev
Browse files Browse the repository at this point in the history
Release version 4.2.0
  • Loading branch information
Frezyx authored Jan 23, 2022
2 parents 5594567 + 2453cdd commit 784db51
Show file tree
Hide file tree
Showing 16 changed files with 267 additions and 143 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 4.2.0
- **FEAT**: Add disabled buttons to controller
- **FEAT**: Add controller fields initialization in controller constructor
- **INFO**: Add deprecatd annotation for selectedButton, selectedButtons and disabledButtons

## 4.1.1
- **FIX**: GroupbuttonController initialization
## 4.1.0
- **FEAT**: [onDisablePressed](https://github.com/Frezyx/group_button/blob/master/lib/src/group_button_base.dart#:~:text=Function(int%20index)%3F-,onDisablePressed,-%3B) calback method for handle taps on disabled buttons

Expand Down
76 changes: 75 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,75 @@
include: package:lint/analysis_options.yaml
linter:
rules:
deprecated_member_use_from_same_package: true
# Good for libraries to prevent unnecessary code paths.
# Dart SDK: >= 2.0.0 • (Linter v0.1.25)
# https://dart-lang.github.io/linter/lints/literal_only_boolean_expressions.html
literal_only_boolean_expressions: true

# One of the most important rules. Docs for package public APIs make a good package.
# Like catching undocumented code? Enable `public_member_api_docs` as well.
# Dart SDK: >= 2.0.0 • (Linter v0.1.1)
# https://dart-lang.github.io/linter/lints/package_api_docs.html
package_api_docs: true

# Too strict. Implementing all exported public APIs (`package_api_docs`) is enough.
# Dart SDK: >= 2.0.0 • (Linter v0.1.11)
# https://dart-lang.github.io/linter/lints/public_member_api_docs.html
# public_member_api_docs

# Adding a key without using it isn't helpful in applications, only for the Flutter SDK
# Dart SDK: >= 2.8.0-dev.1.0 • (Linter v0.1.108)
# https://dart-lang.github.io/linter/lints/use_key_in_widget_constructors.html
use_key_in_widget_constructors: true
always_declare_return_types: true
always_require_non_null_named_parameters: true
annotate_overrides: true
avoid_init_to_null: true
avoid_null_checks_in_equality_operators: true
avoid_relative_lib_imports: true
avoid_return_types_on_setters: true
avoid_shadowing_type_parameters: true
avoid_single_cascade_in_expression_statements: true
avoid_types_as_parameter_names: true
await_only_futures: true
camel_case_extensions: true
curly_braces_in_flow_control_structures: true
empty_catches: true
empty_constructor_bodies: true
library_names: true
library_prefixes: true
no_duplicate_case_values: true
null_closures: true
omit_local_variable_types: true
prefer_adjacent_string_concatenation: true
prefer_collection_literals: true
prefer_conditional_assignment: true
prefer_contains: true
prefer_equal_for_default_values: true
prefer_final_fields: true
prefer_for_elements_to_map_fromIterable: true
prefer_generic_function_type_aliases: true
prefer_if_null_operators: true
prefer_inlined_adds: true
prefer_is_empty: true
prefer_is_not_empty: true
prefer_iterable_whereType: true
prefer_single_quotes: true
prefer_spread_collections: true
recursive_getters: true
slash_for_doc_comments: true
sort_child_properties_last: true
type_init_formals: true
unawaited_futures: true
unnecessary_brace_in_string_interps: true
unnecessary_const: true
unnecessary_getters_setters: true
unnecessary_new: true
unnecessary_null_in_if_null_operators: true
unnecessary_this: true
unrelated_type_equality_checks: true
unsafe_html: true
use_full_hex_values_for_flutter_colors: true
use_function_type_syntax_for_parameters: true
use_rethrow_when_possible: true
valid_regexps: true
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import 'package:group_button/group_button.dart';

class CustomizableExample extends StatelessWidget {
CustomizableExample({Key key}) : super(key: key);
final controller = GroupButtonController();
final customizableController = CustomizableExampleController();

Expand Down
16 changes: 8 additions & 8 deletions example/lib/examples/extended_example/checkbox_example_part.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Widget _buildCheckboxExample(GroupingType groupingType, {Axis direction}) {
child: Center(
child: GroupButton(
isRadio: false,
controller: GroupButtonController(selectedIndexes: const [2, 3]),
groupingType: groupingType,
direction: direction,
selectedShadow: const [],
Expand All @@ -22,15 +23,14 @@ Widget _buildCheckboxExample(GroupingType groupingType, {Axis direction}) {
),
onDisablePressed: (i) => debugPrint('Disable Button #$i pressed'),
buttons: const [
"Burger",
"Sandwiches",
"Salad",
"Carbonara",
"Meat",
"French fries",
"Carbonated beverage"
'Burger',
'Sandwiches',
'Salad',
'Carbonara',
'Meat',
'French fries',
'Carbonated beverage'
],
selectedButtons: const [2, 3],
),
),
),
Expand Down
23 changes: 11 additions & 12 deletions example/lib/examples/extended_example/custom_example_part.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Widget _buildCustomExample(GroupingType groupingType, {Axis direction}) {
child: Padding(
padding: const EdgeInsets.all(10.0),
child: GroupButton(
controller: GroupButtonController(),
controller: GroupButtonController(selectedIndexes: const [1, 2, 3]),
spacing: 5,
isRadio: false,
groupingType: groupingType,
Expand All @@ -16,18 +16,17 @@ Widget _buildCustomExample(GroupingType groupingType, {Axis direction}) {
),
onDisablePressed: (i) => debugPrint('Disable Button #$i pressed'),
buttons: const [
"Dart",
"Kotlin",
"Java",
"Swift",
"Objective-C",
"Python",
"JS",
"C#",
"C",
"C++"
'Dart',
'Kotlin',
'Java',
'Swift',
'Objective-C',
'Python',
'JS',
'C#',
'C',
'C++'
],
selectedButtons: const [1, 2, 3],
selectedTextStyle: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
Expand Down
14 changes: 4 additions & 10 deletions example/lib/examples/extended_example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ part 'checkbox_example_part.dart';
part 'custom_example_part.dart';

class GroupButtonExtendedExample extends StatelessWidget {
GroupButtonExtendedExample({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return MaterialApp(
Expand Down Expand Up @@ -62,11 +64,7 @@ class _ExampleState extends State<_Example> {
controller: GroupButtonController(),
mainGroupAlignment: MainGroupAlignment.start,
groupingType: GroupingType.row,
buttons: const [
"Wrap",
"Column",
"Row",
],
buttons: const ['Wrap', 'Column', 'Row'],
onSelected: (i, selected) {
_extendedExampleController.selectedGroupingType = i;
},
Expand All @@ -78,11 +76,7 @@ class _ExampleState extends State<_Example> {
controller: GroupButtonController(),
mainGroupAlignment: MainGroupAlignment.start,
groupingType: GroupingType.row,
buttons: const [
"Radio",
"CheckBox",
"Custom",
],
buttons: const ['Radio', 'CheckBox', 'Custom'],
onSelected: (i, selected) {
_pageController.animateToPage(
i,
Expand Down
11 changes: 2 additions & 9 deletions example/lib/examples/extended_example/radio_example_part.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,13 @@ Widget _buildRadioExample(GroupingType groupingType, {Axis direction}) {
padding: const EdgeInsets.all(10.0),
child: Center(
child: GroupButton(
controller: GroupButtonController(selectedIndex: 1),
direction: direction,
groupingType: groupingType,
onSelected: (index, isSelected) =>
debugPrint('$index button is selected'),
onDisablePressed: (i) => debugPrint('Disable Button #$i pressed'),
buttons: const [
"12:00",
"13:00",
"14:30",
"18:00",
"19:00",
"21:40",
],
selectedButton: 5,
buttons: const ['12:00', '13:00', '14:30', '18:00', '19:00', '21:40'],
),
),
),
Expand Down
17 changes: 12 additions & 5 deletions example/lib/examples/provider_example/ui/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:group_button/group_button.dart';
import 'package:provider/provider.dart';

class GroupButtonProviderExample extends StatelessWidget {
GroupButtonProviderExample({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return MultiProvider(
Expand All @@ -23,11 +25,13 @@ class GroupButtonProviderExample extends StatelessWidget {
}

class HomePage extends StatefulWidget {
HomePage({Key key}) : super(key: key);

@override
_HomePageState createState() => _HomePageState();
HomePageState createState() => HomePageState();
}

class _HomePageState extends State<HomePage>
class HomePageState extends State<HomePage>
with SingleTickerProviderStateMixin {
Axis direction = Axis.horizontal;

Expand All @@ -39,7 +43,7 @@ class _HomePageState extends State<HomePage>
length: _eProvider.exercise.questions.length,
child: Scaffold(
appBar: AppBar(
title: const Text("GroupButton & Provider"),
title: const Text('GroupButton & Provider'),
bottom: _buildTabBar(_eProvider),
),
body: _buildTabBarView(_eProvider, size),
Expand Down Expand Up @@ -68,16 +72,19 @@ class _HomePageState extends State<HomePage>
GroupButton(
spacing: 15,
isRadio: false,
controller: GroupButtonController(
selectedIndexes: q.selectedIndexes,
),
onSelected: (index, isSelected) {
debugPrint(
'$index button is ${isSelected ? 'selected' : 'unselected'}',
);
_eProvider.updateAnswer(index, value: isSelected);
},
onDisablePressed: (i) => debugPrint('Disable Button #$i pressed'),
onDisablePressed: (i) =>
debugPrint('Disable Button #$i pressed'),
selectedColor: Colors.blue,
buttons: q.answerTitles,
selectedButtons: q.selectedIndexes,
),
],
),
Expand Down
16 changes: 12 additions & 4 deletions example/lib/examples/styles_example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
import 'package:group_button/group_button.dart';

class StylesExample extends StatelessWidget {
StylesExample({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return MaterialApp(
Expand Down Expand Up @@ -35,7 +37,7 @@ class StylesExample extends StatelessWidget {
'17:00',
'18:00',
],
selectedButton: 4,
controller: GroupButtonController(selectedIndex: 4),
selectedShadow: const [],
unselectedShadow: const [],
unselectedColor: Colors.grey[300],
Expand All @@ -62,7 +64,9 @@ class StylesExample extends StatelessWidget {
selectedShadow: const [],
unselectedShadow: const [],
isRadio: false,
selectedButtons: const [1, 3, 4],
controller: GroupButtonController(
selectedIndexes: const [1, 3, 4],
),
selectedColor: Colors.black,
selectedTextStyle: const TextStyle(
fontWeight: FontWeight.w900,
Expand All @@ -86,7 +90,9 @@ class StylesExample extends StatelessWidget {
'18:00',
],
isRadio: false,
selectedButtons: const [0, 4, 6],
controller: GroupButtonController(
selectedIndexes: const [0, 4, 6],
),
selectedShadow: const [],
unselectedShadow: const [],
selectedTextStyle: TextStyle(
Expand Down Expand Up @@ -131,7 +137,9 @@ class StylesExample extends StatelessWidget {
)
],
isRadio: false,
selectedButtons: const [1, 3, 4],
controller: GroupButtonController(
selectedIndexes: const [1, 3, 4],
),
unselectedBorderColor: Colors.grey[400],
selectedBorderColor: Colors.pink,
unselectedTextStyle: const TextStyle(
Expand Down
8 changes: 7 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ void main() {
}

class CommonExample extends StatelessWidget {
final controller = GroupButtonController();
CommonExample({Key key}) : super(key: key);

final controller = GroupButtonController(
selectedIndex: 20,
selectedIndexes: [1, 2, 3, 4, 5],
disabledIndexes: [10, 12, 13, 14, 15],
);

@override
Widget build(BuildContext context) {
Expand Down
Loading

0 comments on commit 784db51

Please sign in to comment.