Giter VIP home page Giter VIP logo

Comments (12)

peterLam2 avatar peterLam2 commented on July 23, 2024

and the DecoratedBox indicator not showing on first start up applications

from animated_toggle_switch.

maeddin avatar maeddin commented on July 23, 2024

I'll take a look at it in a few hours. Where is SPAColor and SPAColorSet implemented?

from animated_toggle_switch.

peterLam2 avatar peterLam2 commented on July 23, 2024

It is a custom colour library,it just turn the hex code into colour, convert two different colour into gradient

from animated_toggle_switch.

maeddin avatar maeddin commented on July 23, 2024

I'll take a closer look at the bug, but for your use case, doesn't it make more sense to use my other package action_slider?

from animated_toggle_switch.

peterLam2 avatar peterLam2 commented on July 23, 2024

Actually I want a switch button that have tap and dragging event , thanks for the advice anyway

from animated_toggle_switch.

maeddin avatar maeddin commented on July 23, 2024

I've fixed the problem. You have to use double.infinity instead of double.maxFinite for dif and set the current version in your pubspec.yaml:

animated_toggle_switch:
    git: https://github.com/SplashByte/animated_toggle_switch.git

It would be great if you verify that the problem is indeed fixed.

from animated_toggle_switch.

maeddin avatar maeddin commented on July 23, 2024

Here is an optimized version of your widget. I have added a transition between the texts:

class _HomePageSliderState extends State<HomePageSlider> {
  bool tripStart = false;

  @override
  Widget build(BuildContext context) {
    return CustomAnimatedToggleSwitch<bool>(
      current: tripStart,
      values: [false, true],
      dif: double.infinity,
      iconArrangement: IconArrangement.overlap,
      // left right 3
      padding: const EdgeInsets.symmetric(horizontal: 3.0),
      indicatorSize: const Size.square(42.0),
      animationDuration: const Duration(milliseconds: 200),
      animationCurve: Curves.linear,
      onChanged: (b) => setState(() => tripStart = b),
      //  Container for The Another Side  Not in used
      iconBuilder: (context, local, global) {
        return Center(
          child: Opacity(
            opacity: local.value ? 1.0 - global.position : global.position,
            child: Text(
            local.value ? '立即Call車' : '截車中',
            style: TextStyle(
              color: Colors.white,
              //Color.lerp(Colors.black, Colors.white, global.position),
              fontSize: 16.0,
              fontFamily: 'NotoSansHK',
              fontWeight: FontWeight.w600,
            ),
          ),),
        );
      },
      defaultCursor: SystemMouseCursors.click,
      onTap: () => setState(() => tripStart = !tripStart),
      iconsTappable: false,

      // container for the Switch Button
      foregroundIndicatorBuilder: (context, global) {
        return SizedBox.fromSize(
          size: global.indicatorSize,
          child: DecoratedBox(
              decoration: BoxDecoration(
                color: Colors.white,
                //Color.lerp(Colors.white, Colors.blue, global.position),
                borderRadius: BorderRadius.all(Radius.circular(24.0)),
              ),
              child: AnimatedContainer(
                // top 5 left 5 bottom 5 right 6
                padding: const EdgeInsets.fromLTRB(5.0, 5.0, 6.0, 5.0),
                duration: const Duration(milliseconds: 200),
                child: Icon(
                  tripStart ? Icons.close : Icons.arrow_forward_ios,
                  color: Color.lerp(Colors.blue, Colors.black, global.position),
                ),
              )),
        );
      },
      // container for the slider
      wrapperBuilder: (context, global, child) {
        return Stack(
          alignment: Alignment.center,
          children: [
            Positioned(
                left: 0.0,
                right: 0.0,
                height: 48,
                child: DecoratedBox(
                  decoration: BoxDecoration(
                    gradient: Gradient.lerp(
                       SPAColorSet.PrimaryGradient.gradient,
                       SPAColor.getGradientColor(['FFFFFF', '222222']),
                       global.position
                    ),
                    // color: Color.lerp(SPAColor.getColorFromHex('2A7DDE'),
                    //     SPAColor.getColorFromHex('5FCFFF'), global.position),
                    borderRadius: const BorderRadius.all(Radius.circular(24.0)),
                  ),
                )),
            child,
          ],
        );
      },
    );
  }}

from animated_toggle_switch.

peterLam2 avatar peterLam2 commented on July 23, 2024

Thanks for the help, the problem fixed , the iconBuilder will as a child render in the wrapperBuilder
did i understand the situation correctly?

from animated_toggle_switch.

peterLam2 avatar peterLam2 commented on July 23, 2024

I close the Issue now , Thanks for your help

from animated_toggle_switch.

maeddin avatar maeddin commented on July 23, 2024

@peterLam2 Thanks for reporting the issue.
Yes, the results of the iconBuilder are part of the child in the wrapperBuilder 👍

from animated_toggle_switch.

maeddin avatar maeddin commented on July 23, 2024

@peterLam2 I don't know if this helps you, but I added two new parameters to AnimatedToggleSwitch.dual. Maybe you can replace your custom switch with AnimatedToggleSwitch.dual now.
You can now disable the rolling animation and set a gradient for the background.

from animated_toggle_switch.

peterLam2 avatar peterLam2 commented on July 23, 2024

Good to hear that 🤠 i will check that tomorrow

from animated_toggle_switch.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.