From 579fb8e2602a0f3a400cd7e6a39e32e6179068a5 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Mon, 1 Mar 2021 16:25:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8A=BD=E5=B1=89=E6=89=93?= =?UTF-8?q?=E5=BC=80=E7=9A=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/lib/widgets/example_drawer.dart | 10 ++++++++- lib/drawer/as_drawer.dart | 28 +++++++++++++++++++++++++ pubspec.lock | 7 +++++++ pubspec.yaml | 1 + 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/example/lib/widgets/example_drawer.dart b/example/lib/widgets/example_drawer.dart index 517ad8d..b43f32a 100644 --- a/example/lib/widgets/example_drawer.dart +++ b/example/lib/widgets/example_drawer.dart @@ -28,7 +28,15 @@ class _ExampleDrawerState extends State { return ASLongButton.solid( title: 'DRAWER', onPressed: () { - Scaffold.of(context).openEndDrawer(); + showASDrawer(ASDrawer( + children: [ + Text('title'), + ], + bottom: ASLongButton.solid( + title: '确定', + onPressed: () {}, + ), + )); }, ); }, diff --git a/lib/drawer/as_drawer.dart b/lib/drawer/as_drawer.dart index 72784fa..59cd846 100644 --- a/lib/drawer/as_drawer.dart +++ b/lib/drawer/as_drawer.dart @@ -1,8 +1,36 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:ansu_ui/utils/screen_adapter.dart'; +import 'package:get/get.dart'; + +///打开抽屉 +Future showASDrawer(Widget drawer) async { + return await Get.generalDialog( + pageBuilder: (context, animation, secondAnimation) { + return drawer; + }, + transitionBuilder: (context, animation, secondaryAnimation, child) { + return SlideTransition( + position: Tween( + end: Offset(0, 0), + begin: Offset(1, 0), + ).animate( + CurvedAnimation( + parent: animation, + curve: Curves.easeInOutCubic, + ), + ), + child: child, + ); + }, + barrierDismissible: true, + barrierLabel: 'filter', + ); +} ///安速抽屉 +/// +///使用`showASDrawer`打开抽屉,不推荐使用`Scaffold`的`drawer`和`endDrawer`打开抽屉。 class ASDrawer extends StatefulWidget { ///子组件List Children /// diff --git a/pubspec.lock b/pubspec.lock index 9ef01ef..b363d7c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -118,6 +118,13 @@ packages: description: flutter source: sdk version: "0.0.0" + get: + dependency: "direct main" + description: + name: get + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.25.6" http: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 614f69e..f5abe08 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -20,6 +20,7 @@ dependencies: aku_ui: git: url: http://test.akuhotel.com:8099/aku_fe/aku_ui.git + get: dev_dependencies: flutter_test: