패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.0.0

pimp_my_button

모든 누를 수 있는 객체에 필요한 기능을 추가하는 패키지입니다.

30일 다운로드
107
좋아요
71
Pub 점수
40

패키지 설치

flutter pub add pimp_my_button

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Pimp My Button은 사용자 정의 가능한 시각적 효과, 애니메이션 및 피드백을 통해 클릭 가능한 위젯을 향상시키는 플러터 패키지입니다. 버튼과 기타 상호작용 요소에 '펌프드'한 외관과 느낌을 더하여 더욱 매력적이고 시각적으로 끌리는 요소로 만들어 줍니다. 복잡한 커스텀 코드 없이 사용자 인터페이스 미학을 한층 높이고 싶은 개발자를 위한 것으로, 기존 플러터 프로젝트에 원활하게 통합됩니다. 이 패키지는 미세하지만 강력한 터치 반응과 동적 스타일링 옵션을 통해 사용자 경험을 개선하는 데 중점을 두고 있습니다.

사용 사례

  • 모바일 앱의 버튼 시각적 요소 개선
  • 사용자 상호작용에 애니메이션 피드백 추가하기
  • 게임 또는 대시보드에서 UI 참여도 향상
  • 재미있거나 브랜드화된 인터랙티브 요소 만들기
  • 최소한의 코드로 눌림 위젯 맞춤설정하기

주요 기능

  • 애니메이션 터치 효과
  • 사용자 정의 가능한 시각적 피드백
  • 기존 위젯과의 간편한 통합
  • 다양한 누를 수 있는 컴포넌트를 지원합니다
  • 경량이고 성능이 뛰어남

적합한 대상

  • 화려함을 더하고 싶은 UI 디자이너
  • 인터랙티브 프로토타입을 구축하는 개발자
  • 사용자 참여에 초점을 맞춘 앱
  • 게임 또는 창의적 응용 프로그램
  • 빠른 UI 개선을 우선시하는 팀

고려 사항

  • 클릭 가능한 위젯만 가능
  • Flutter 플랫폼 외 지원 없음
  • 복잡한 레이아웃을 위해 추가 스타일링이 필요할 수 있습니다
  • 접근성 중심 애플리케이션에 적합하지 않습니다
  • 외부 애니메이션 라이브러리에 의존합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Showcase

pimp_my_button-showcase

Features

  • Highly customizable (Don't like my particle effects? Make your own with little effort!)
  • Very easy to use
  • A lot of premade particles

Installation

I will publish this package on pub if people enjoy it. So leave a star if you do ;)

dependencies:
  pimp_my_button: ^1.0.0

run packages get and import it

import 'package:pimp_my_button/pimp_my_button.dart';

If you are not able to import it, restart your IDE see: https://github.com/flutter/flutter/issues/17016

Basics

The basic setup looks like this:

PimpedButton(
  particle: DemoParticle(),
  pimpedWidgetBuilder: (context, controller) {
    return FloatingActionButton(onPressed: () {
      controller.forward(from: 0.0);
    },);
  },
);

The pimpedWidgetBuilder uses a builder which besides providing a new context and an AnimationController. When your button is pressed call this code:

controller.forward(from: 0.0);

It's important to include the from field because otherwise the animation won't play after the first tap.

The particle specified in the PimpedButton controlls what the animation looks like.

Demo Particle Walk Through

We'll walk through how to build a Particle yourself, step by step.

Here is what were are going to build:

fab

Each particle has to extend Particle and override this method: void paint(Canvas canvas, Size size, progress, seed)

  • Canvas is the canvas you can paint on
  • The size is the bounding box of the the enclosing widget
  • Progress is a double between 0 and 1, it reflects the progress in the animation
  • The seed is an int value generated once for every tap. When dealing with randoms, initialize your Random with that seed (so every frame is synced)

The first particle

CompositeParticle(
  children: []
).paint(canvas, size, progressm seed);

You have to paint atleast one Particle in the paint(.,.,.,) method. Usually this would be the CompositeParticle.

The CompositeParticle doesn't do much on its own. It only paints all of its children.

Adding actual particles

The next interesting particle is the CircleMirror and RectangeMirror.

    CircleMirror(
        numberOfParticles: 6,
        child: AnimatedPositionedParticle(
          begin: Offset(0.0, 20.0),
          end: Offset(0.0, 60.0),
          child: FadingRect(width: 5.0, height: 15.0, color: Colors.pink),
        ),
        initialRotation: -pi / randomMirrorOffset),

This mirrors its particle around the middle point in a circular shape. In this case you provide one Particle which is going to be drawn multiple times, thus looking identical. If you want different particles (or the same with randomized values), use the CircleMirror.builder.

At the bottom of the hierarchy is the FadingRect, all it does is drawing a rectangle which fades out over time. To make it move, it's wrapped in an AnimatedPositionedParticle.

This is the full code:

class DemoParticle extends Particle {
  @override
  void paint(Canvas canvas, Size size, progress, seed) {
    Random random = Random(seed);
    int randomMirrorOffset = random.nextInt(8) + 1;
    CompositeParticle(children: [
      Firework(),
      CircleMirror(
          numberOfParticles: 6,
          child: AnimatedPositionedParticle(
            begin: Offset(0.0, 20.0),
            end: Offset(0.0, 60.0),
            child: FadingRect(width: 5.0, height: 15.0, color: Colors.pink),
          ),
          initialRotation: -pi / randomMirrorOffset),
      CircleMirror.builder(
          numberOfParticles: 6,
          particleBuilder: (index) {
            return IntervalParticle(
                child: AnimatedPositionedParticle(
                  begin: Offset(0.0, 30.0),
                  end: Offset(0.0, 50.0),
                  child: FadingTriangle(
                      baseSize: 6.0 + random.nextDouble() * 4.0,
                      heightToBaseFactor: 1.0 + random.nextDouble(),
                      variation: random.nextDouble(),
                      color: Colors.green),
                ),
                interval: Interval(
                  0.0,
                  0.8,
                ));
          },
          // division by 0 is not good ;)
          initialRotation: -pi / randomMirrorOffset + 8),
    ]).paint(canvas, size, progress, seed);
  }
}

Notes

Some particles worth checking out:
  • IntervalParticle, applies an interval and/or curve to the child.
  • FourRandomSlotParticle, positions 4 children on the different sections.
  • PoppingCircle, pretty popping circle
Check out other demo particles:

https://github.com/Norbert515/pimp_my_button/blob/master/lib/src/demo_particles.dart

You are not restricted to use the particles in the context of "Pimp my button", the particles can be drawn on any regular canvas.

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.