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

Allow cards to have the same size,新增keepLast:是否保留最后一张卡片,完善禁止拖拽 #53

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

lizhuoyuan
Copy link

@lizhuoyuan lizhuoyuan commented Nov 28, 2022

Allow cards to have the same size
add param : sameSize
If it is not used, there is no change between and now
image

keepLast 最后一张滑动后是否保留(默认为false,与现在一样,true:最后一张滑动后会再次出现在这里)
enableDrag 是否开启滑动功能 默认 true
endTips 全部滑动完成后展示的组件

@lizhuoyuan lizhuoyuan changed the title Allow cards to have the same size Allow cards to have the same size,新增keepLast:是否保留最后一张卡片,完善禁止拖拽 Dec 1, 2022
@lizhuoyuan
Copy link
Author

example :

import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_tantan/card_widget.dart';
import 'package:tcard/tcard.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const ExampleHomePage(),
    );
  }
}

class ExampleHomePage extends StatefulWidget {
  const ExampleHomePage({Key? key}) : super(key: key);

  @override
  State<ExampleHomePage> createState() => _ExampleHomePageState();
}

class _ExampleHomePageState extends State<ExampleHomePage> with TickerProviderStateMixin {
  static Color myColor() => Color.fromARGB(
        255,
        Random.secure().nextInt(200),
        Random.secure().nextInt(200),
        Random.secure().nextInt(200),
      );

  List<Color> colors = [
    myColor(),
    myColor(),
    myColor(),
    myColor(),
    myColor(),
  ];

  bool enable = true;

  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.white60,
      child: SafeArea(
          child: UnconstrainedBox(
        child: Container(
          color: Colors.green,
          child: Stack(
            children: [
              TCard(
                keepLast: true,
                enableDrag: enable,
                onEnd: () {
                  setState(() {
                    enable = false;
                  });
                },
                onForward: (index, info) {
                  print(index);
                },
                size: Size(300, 400) / 0.9,
                cards: colors.map((Color e) => CardWidget(300, 400, e)).toList(),
              ),
            ],
          ),
        ),
      )),
    );
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant