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

61 vertical switch #62

Merged
merged 9 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.8.3

- adds support for vertical switches ([#61](https://github.com/splashbyte/animated_toggle_switch/issues/61))

## 0.8.2 (2024-02-26)

- adds `clipBehavior` to `AnimatedToggleSwitch` ([#56](https://github.com/splashbyte/animated_toggle_switch/issues/56))
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

Fully customizable, draggable and animated switch with multiple choices and [smooth loading animation](#loading-animation). It has prebuilt constructors for rolling and size animations, but it also allows you to create your own switches with `CustomAnimatedToggleSwitch`.
`LTR` and `RTL` are both supported.
[Switches without an (initial) selection](#nullable-selection) are also possible.
Most builder arguments of `AnimatedToggleSwitch` have a standard and a custom version. This ensures that you can [get started easily](#simple-rolling-animation) and still customize a lot if necessary. There are several options for [styling](#styling) it.
[Switches without an (initial) selection](#nullable-selection) and [vertical switches](#vertical-switches) are also possible.
Most builder arguments of `AnimatedToggleSwitch` have standard and a custom version. This ensures that you can [get started easily](#simple-rolling-animation) and still customize a lot if necessary. There are several options for [styling](#styling) it.

For a slider with a similar look you can check out [action_slider](https://pub.dev/packages/action_slider).

Expand Down Expand Up @@ -129,6 +129,14 @@ AnimatedToggleSwitch<int?>.rolling(
)
```

### Vertical switches
![animated_toggle_switch_example_vertical](https://github.com/user-attachments/assets/b6b804d0-a8f0-47a2-bf73-e9e0b65773d7)
You can get a vertical version of any switch by calling `vertical()` on it.

```dart
AnimatedToggleSwitch<int?>.rolling(...).vertical()
```

### Fully customizable toggle switch with `CustomAnimatedToggleSwitch`

```dart
Expand Down
1 change: 0 additions & 1 deletion example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import Flutter

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
4 changes: 2 additions & 2 deletions example/lib/crazy_switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class _CrazySwitchState extends State<CrazySwitch> {
return CustomAnimatedToggleSwitch(
current: current,
spacing: 36.0,
values: [false, true],
values: const [false, true],
animationDuration: const Duration(milliseconds: 350),
animationCurve: Curves.bounceOut,
iconBuilder: (context, local, global) => const SizedBox(),
Expand All @@ -41,7 +41,7 @@ class _CrazySwitchState extends State<CrazySwitch> {
return Container(
alignment: Alignment.center,
decoration:
BoxDecoration(color: Colors.white, shape: BoxShape.circle),
const BoxDecoration(color: Colors.white, shape: BoxShape.circle),
child: Container(
width: innerIndicatorSize * 0.4 +
global.position * innerIndicatorSize * 0.6,
Expand Down
8 changes: 4 additions & 4 deletions example/lib/load_switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class _LoadSwitchState extends State<LoadSwitch> {
const borderWidth = 5.0;
return CustomAnimatedToggleSwitch(
height: height,
indicatorSize: Size.square(height),
indicatorSize: const Size.square(height),
current: value,
values: [false, true],
values: const [false, true],
onChanged: (newValue) {
setState(() => value = newValue);
return Future.delayed(const Duration(seconds: 2));
Expand All @@ -42,8 +42,8 @@ class _LoadSwitchState extends State<LoadSwitch> {
return Stack(
fit: StackFit.expand,
children: [
Padding(
padding: const EdgeInsets.all(borderWidth),
const Padding(
padding: EdgeInsets.all(borderWidth),
child: DecoratedBox(
decoration: BoxDecoration(
shape: BoxShape.circle, color: Colors.white)),
Expand Down
Loading
Loading