Skip to content

Commit

Permalink
version 2.3.0 changes:
Browse files Browse the repository at this point in the history
  * Added customWidgets option:
    - overrides default widgets, foreground colors
    - parameter:
        - customWidgets (optional, type List<Widget>)
  * Added CustomBorderPaint class to optimize gradient border
  * Restructured project with src folder
  * Code cleanups
  • Loading branch information
PramodJoshi committed Mar 25, 2024
1 parent 0bcbcfc commit 840b559
Show file tree
Hide file tree
Showing 14 changed files with 694 additions and 263 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 2.3.0
* Added customWidgets option:
- overrides default widgets, foreground colors
- parameter:
- customWidgets (optional, type List\<Widget>)
* Added CustomBorderPaint class to optimize gradient border
* Restructured project with src folder
* Code cleanups

## 2.2.3
* Fixed center text issue

Expand All @@ -17,7 +26,7 @@
* Updated SDK to 4.0.0, modifier fixes ([PR 83](https://github.com/PramodJoshi/toggle_switch/pull/83/files))
* Added toggle disable functionality ([PR 81](https://github.com/PramodJoshi/toggle_switch/pull/81/files)):
- parameter:
- states (optional, type List<bool>)
- states (optional, type List\<bool>)

## 2.1.0
* Added cancel toggle function ([PR 77](https://github.com/PramodJoshi/toggle_switch/pull/77/files)):
Expand Down
112 changes: 109 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: ^2.2.3
toggle_switch: ^2.3.0
```
Import it:
Expand Down Expand Up @@ -128,7 +128,7 @@ ToggleSwitch(
),
```

![With border color, border width, icons, custom height and different active background colors](https://media.giphy.com/media/yKLaQurj8KvjLaYte0/giphy.gif)
![With border color, border width, icons, custom height and different active background colors](https://media.giphy.com/media/8881VEqgaGFDlUo1jb/giphy.gif)

### With gradient border color, divider color and gradient active background colors

Expand Down Expand Up @@ -157,7 +157,7 @@ ToggleSwitch(
),
```

![With gradient border color, divider color and gradient active background colors](https://media.giphy.com/media/wIYpfehKbfQFjXmlKC/giphy.gif)
![With gradient border color, divider color and gradient active background colors](https://media.giphy.com/media/mfjwHe9w1WG0UIZvqF/giphy.gif)

### With bounceInOut animation

Expand Down Expand Up @@ -441,6 +441,112 @@ ToggleSwitch(

![Cancel toggle](https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExZWNhOGJhNjMzNWNjNmNmOWYwMGI0Nzc3YWEyNjdhYTIyNTRmMDQ2MSZlcD12MV9pbnRlcm5hbF9naWZzX2dpZklkJmN0PWc/qHB8oy90lXIfyQE0vi/giphy.gif)

### Custom widgets

```dart
ToggleSwitch(
initialLabelIndex: 0,
minHeight: 75.0,
minWidth: double.maxFinite,
activeBgColor: [Colors.blue.shade50],
inactiveBgColor: Colors.white,
dividerColor: Colors.blue,
borderColor: [Colors.blue],
borderWidth: 1.0,
customWidgets: [
// Overrides default widgets, foreground colors
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
FontAwesomeIcons.star,
),
const SizedBox(width: 10.0),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Free',
style: TextStyle(
fontWeight: FontWeight.bold,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
'\$0.00',
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
FontAwesomeIcons.solidStar,
color: Color(0xffC0C0C0),
),
const SizedBox(width: 10.0),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Standard',
style: TextStyle(
fontWeight: FontWeight.bold,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
'\$4.99',
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
FontAwesomeIcons.solidStar,
color: Color(0xffFFD700),
),
const SizedBox(width: 10.0),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Pro',
style: TextStyle(
fontWeight: FontWeight.bold,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
'\$9.99',
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
],
),
],
onToggle: (index) {
print('switched to: $index');
},
),
```

![Custom widgets](https://media.giphy.com/media/VFcY7CM1Vq9cMkxiTR/giphy.gif)

### TextDirection.rtl and corner radius

```dart
Expand Down
112 changes: 109 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: ^2.2.3
toggle_switch: ^2.3.0
```
Import it:
Expand Down Expand Up @@ -128,7 +128,7 @@ ToggleSwitch(
),
```

![With border color, border width, icons, custom height and different active background colors](https://media.giphy.com/media/yKLaQurj8KvjLaYte0/giphy.gif)
![With border color, border width, icons, custom height and different active background colors](https://media.giphy.com/media/8881VEqgaGFDlUo1jb/giphy.gif)

### With gradient border color, divider color and gradient active background colors

Expand Down Expand Up @@ -157,7 +157,7 @@ ToggleSwitch(
),
```

![With gradient border color, divider color and gradient active background colors](https://media.giphy.com/media/wIYpfehKbfQFjXmlKC/giphy.gif)
![With gradient border color, divider color and gradient active background colors](https://media.giphy.com/media/mfjwHe9w1WG0UIZvqF/giphy.gif)

### With bounceInOut animation

Expand Down Expand Up @@ -441,6 +441,112 @@ ToggleSwitch(

![Cancel toggle](https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExZWNhOGJhNjMzNWNjNmNmOWYwMGI0Nzc3YWEyNjdhYTIyNTRmMDQ2MSZlcD12MV9pbnRlcm5hbF9naWZzX2dpZklkJmN0PWc/qHB8oy90lXIfyQE0vi/giphy.gif)

### Custom widgets

```dart
ToggleSwitch(
initialLabelIndex: 0,
minHeight: 75.0,
minWidth: double.maxFinite,
activeBgColor: [Colors.blue.shade50],
inactiveBgColor: Colors.white,
dividerColor: Colors.blue,
borderColor: [Colors.blue],
borderWidth: 1.0,
customWidgets: [
// Overrides default widgets, foreground colors
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
FontAwesomeIcons.star,
),
const SizedBox(width: 10.0),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Free',
style: TextStyle(
fontWeight: FontWeight.bold,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
'\$0.00',
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
FontAwesomeIcons.solidStar,
color: Color(0xffC0C0C0),
),
const SizedBox(width: 10.0),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Standard',
style: TextStyle(
fontWeight: FontWeight.bold,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
'\$4.99',
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
FontAwesomeIcons.solidStar,
color: Color(0xffFFD700),
),
const SizedBox(width: 10.0),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Pro',
style: TextStyle(
fontWeight: FontWeight.bold,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
'\$9.99',
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
],
),
],
onToggle: (index) {
print('switched to: $index');
},
),
```

![Custom widgets](https://media.giphy.com/media/VFcY7CM1Vq9cMkxiTR/giphy.gif)

### TextDirection.rtl and corner radius

```dart
Expand Down
Loading

0 comments on commit 840b559

Please sign in to comment.