Skip to content

Commit

Permalink
version 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
PramodJoshi committed Apr 15, 2022
1 parent c3f4430 commit 99fedfd
Show file tree
Hide file tree
Showing 8 changed files with 459 additions and 105 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## 2.0.1
* Added vertical toggle switch option ([PR 51](https://github.com/PramodJoshi/toggle_switch/pull/51/files)):
- parameter:
- isVertical (type bool - default false)
* Added active borders option (Partial implementation from [PR 53](https://github.com/PramodJoshi/toggle_switch/pull/53/files)):
- parameter:
- activeBorders (optional, type List<Border>)
- list with only one Border value will apply that Border to all the active switches
- different Border values can be provided for different switches
* Added divider margin option:
- parameter:
- dividerMargin (optional, type double - default 8.0)
* Made totalSwitches parameter optional.
* Added new changes to customTextStyles:
- list with only one TextStyle value will apply that TextStyle to all the active switches
* Added new changes to customWidths:
- customWidths can now reflect widths greater than device width
- must use horizontal scroll view to prevent overflow

## 1.4.0
* Minor bug fix ([PR 44](https://github.com/PramodJoshi/toggle_switch/pull/44)).
- return null when active switch is de-activated by re-tapping
Expand Down
80 changes: 77 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ In the `pubspec.yaml` of your flutter project, add the following dependency:
```yaml
dependencies:
...
toggle_switch: ^1.4.0
toggle_switch: ^2.0.1
```
Import it:
Expand Down Expand Up @@ -279,6 +279,80 @@ ToggleSwitch(

![With custom icons](https://media.giphy.com/media/VZFytiPYc7CssuDzJS/giphy.gif)

### Vertical toggle switch with active border

```dart
ToggleSwitch(
activeBorders: [
Border.all(
color: Colors.purple,
width: 3.0,
),
Border.all(
color: Colors.yellow.shade700,
width: 3.0,
),
Border.all(
color: Colors.deepOrangeAccent,
width: 3.0,
),
Border.all(
color: Colors.blue.shade500,
width: 3.0,
),
],
activeFgColor: Colors.black54,
isVertical: true,
minWidth: 150.0,
radiusStyle: true,
cornerRadius: 20.0,
initialLabelIndex: 2,
activeBgColors: [
[Colors.purpleAccent],
[Colors.yellow],
[Colors.orange],
[Colors.lightBlueAccent]
],
labels: ['Spring', 'Summer', 'Fall', 'Winter'],
onToggle: (index) {
print('switched to: $index');
},
),
```

![Vertical toggle switch with active border](https://media.giphy.com/media/eFjXTBhH913cYWWYU3/giphy.gif)

### Custom widths greater than device width

```dart
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Scrollbar(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: ToggleSwitch(
customWidths: [300.0, 100.0, 100.0],
cornerRadius: 20.0,
activeBgColors: [
[Colors.green],
[Colors.redAccent],
[Colors.blue]
],
activeFgColor: Colors.white,
inactiveBgColor: Colors.grey,
inactiveFgColor: Colors.white,
labels: ['Yes, the statement above is true', 'False', 'Other'],
onToggle: (index) {
print('switched to: $index');
},
),
),
),
),
```

![Custom widths greater than device width](https://media.giphy.com/media/ZkF9MlIm9y1H9baWrZ/giphy.gif)

### TextDirection.rtl and corner radius

```dart
Expand All @@ -305,6 +379,6 @@ Directionality(

[Example code with explanation](https://github.com/PramodJoshi/toggle_switch/issues/11#issuecomment-679277018)

## Credits
## Code Contributors

[Eugene](https://stackoverflow.com/questions/56340682/flutter-equvalent-android-toggle-switch)
[![](https://contrib.rocks/image?repo=PramodJoshi/toggle_switch)](https://github.com/PramodJoshi/toggle_switch/graphs/contributors)
80 changes: 77 additions & 3 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ In the `pubspec.yaml` of your flutter project, add the following dependency:
```yaml
dependencies:
...
toggle_switch: ^1.4.0
toggle_switch: ^2.0.1
```
Import it:
Expand Down Expand Up @@ -279,6 +279,80 @@ ToggleSwitch(

![With custom icons](https://media.giphy.com/media/VZFytiPYc7CssuDzJS/giphy.gif)

### Vertical toggle switch with active border

```dart
ToggleSwitch(
activeBorders: [
Border.all(
color: Colors.purple,
width: 3.0,
),
Border.all(
color: Colors.yellow.shade700,
width: 3.0,
),
Border.all(
color: Colors.deepOrangeAccent,
width: 3.0,
),
Border.all(
color: Colors.blue.shade500,
width: 3.0,
),
],
activeFgColor: Colors.black54,
isVertical: true,
minWidth: 150.0,
radiusStyle: true,
cornerRadius: 20.0,
initialLabelIndex: 2,
activeBgColors: [
[Colors.purpleAccent],
[Colors.yellow],
[Colors.orange],
[Colors.lightBlueAccent]
],
labels: ['Spring', 'Summer', 'Fall', 'Winter'],
onToggle: (index) {
print('switched to: $index');
},
),
```

![Vertical toggle switch with active border](https://media.giphy.com/media/eFjXTBhH913cYWWYU3/giphy.gif)

### Custom widths greater than device width

```dart
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Scrollbar(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: ToggleSwitch(
customWidths: [300.0, 100.0, 100.0],
cornerRadius: 20.0,
activeBgColors: [
[Colors.green],
[Colors.redAccent],
[Colors.blue]
],
activeFgColor: Colors.white,
inactiveBgColor: Colors.grey,
inactiveFgColor: Colors.white,
labels: ['Yes, the statement above is true', 'False', 'Other'],
onToggle: (index) {
print('switched to: $index');
},
),
),
),
),
```

![Custom widths greater than device width](https://media.giphy.com/media/ZkF9MlIm9y1H9baWrZ/giphy.gif)

### TextDirection.rtl and corner radius

```dart
Expand All @@ -305,6 +379,6 @@ Directionality(

[Example code with explanation](https://github.com/PramodJoshi/toggle_switch/issues/11#issuecomment-679277018)

## Credits
## Code Contributors

[Eugene](https://stackoverflow.com/questions/56340682/flutter-equvalent-android-toggle-switch)
[![](https://contrib.rocks/image?repo=PramodJoshi/toggle_switch)](https://github.com/PramodJoshi/toggle_switch/graphs/contributors)
82 changes: 78 additions & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ class MyApp extends StatelessWidget {
),
),
ToggleSwitch(
activeBorder: Border.all(
color: Color(0xFFFD5C14),
width: 1,
),
initialLabelIndex: 0,
totalSwitches: 3,
labels: ['America', 'Canada', 'Mexico'],
Expand Down Expand Up @@ -315,6 +311,84 @@ class MyApp extends StatelessWidget {
print('switched to: $index');
},
),
Padding(
padding: const EdgeInsets.all(20.0),
child: Text(
'Vertical toggle switch with active border:',
style: TextStyle(fontWeight: FontWeight.bold),
),
),
ToggleSwitch(
activeBorders: [
Border.all(
color: Colors.purple.shade300,
width: 3.0,
),
Border.all(
color: Colors.yellow.shade500,
width: 3.0,
),
Border.all(
color: Colors.orange.shade300,
width: 3.0,
),
Border.all(
color: Colors.blue.shade300,
width: 3.0,
),
],
activeFgColor: Colors.black54,
isVertical: true,
minWidth: 150.0,
radiusStyle: true,
cornerRadius: 20.0,
initialLabelIndex: 2,
activeBgColors: [
[Colors.purple.shade100],
[Colors.yellow.shade100],
[Colors.orange.shade100],
[Colors.blue.shade100]
],
labels: ['Spring', 'Summer', 'Fall', 'Winter'],
onToggle: (index) {
print('switched to: $index');
},
),
Padding(
padding: const EdgeInsets.all(20.0),
child: Text(
'Custom widths greater than device width:',
style: TextStyle(fontWeight: FontWeight.bold),
),
),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Scrollbar(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: ToggleSwitch(
customWidths: [300.0, 100.0, 100.0],
cornerRadius: 20.0,
activeBgColors: [
[Colors.green],
[Colors.redAccent],
[Colors.blue]
],
activeFgColor: Colors.white,
inactiveBgColor: Colors.grey,
inactiveFgColor: Colors.white,
labels: [
'Yes, the statement above is true',
'False',
'Other'
],
onToggle: (index) {
print('switched to: $index');
},
),
),
),
),
],
),
)),
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.4.0"
version: "2.0.0"
typed_data:
dependency: transitive
description:
Expand Down
Loading

0 comments on commit 99fedfd

Please sign in to comment.