Skip to content

Commit

Permalink
add #181 demo
Browse files Browse the repository at this point in the history
  • Loading branch information
xdd666t committed Mar 26, 2024
1 parent 03778c4 commit 6eca4e9
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 7 deletions.
130 changes: 130 additions & 0 deletions example/lib/demo/issue181_overstep.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';

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

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

@override
Widget build(BuildContext context) {
return MaterialApp(
// home: const _TestingDialog(),
home: const DialogTestPage(),
navigatorObservers: [FlutterSmartDialog.observer],
builder: FlutterSmartDialog.init(),
);
}
}

class DialogTestPage extends StatelessWidget {
const DialogTestPage({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.green,
floatingActionButton: FloatingActionButton(
onPressed: () {
SmartDialog.show(
clickMaskDismiss: false,
builder: (_) => const _TestingDialog(),
);
},
child: const Icon(Icons.add),
),
);
}
}

class _TestingDialog extends StatefulWidget {
const _TestingDialog();

@override
State<_TestingDialog> createState() => _TestingDialogState();
}

class _TestingDialogState extends State<_TestingDialog>
with SingleTickerProviderStateMixin {
late AnimationController animationController;
Tween<double> tween = Tween(begin: 0, end: 50);

@override
void initState() {
super.initState();
animationController = AnimationController(
duration: const Duration(milliseconds: 800),
vsync: this,
);

WidgetsBinding.instance.addPostFrameCallback((_) {
Future.delayed(const Duration(milliseconds: 300), () {
animationController.forward();
});
});
}

@override
void dispose() {
animationController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Center(
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 16),
child: Stack(
clipBehavior: Clip.none,
alignment: Alignment.bottomCenter,
children: [
// 这里,点击事件也可以传递到遮罩
SizedBox(height: MediaQuery.of(context).size.height,width: MediaQuery.of(context).size.width),
Container(height: 300, color: Colors.blue),
AnimatedBuilder(
animation: animationController,
builder: (_, child) {
return Transform.translate(
offset:
Offset(0, -(100 + tween.evaluate(animationController))),
child: child,
);
},
child: Container(
height: 200,
width: 200,
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
InkWell(
onTap: () {
SmartDialog.dismiss();
print("111111111111");
},
child: const Row(children: [
Icon(Icons.close),
Text('<-用不了的'),
]),
),
InkWell(
onTap: () {
SmartDialog.dismiss();
print("2222222222222");
},
child: const Row(children: [
Icon(Icons.close),
Text('<-能用的'),
]),
),
],
),
),
),
],
),
),
);
}
}
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ">=2.17.0 <3.0.0"

dependencies:
flutter:
Expand Down
7 changes: 6 additions & 1 deletion example/windows/flutter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ include(${EPHEMERAL_DIR}/generated_config.cmake)
# https://github.com/flutter/flutter/issues/57146.
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")

# Set fallback configurations for older versions of the flutter tool.
if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
set(FLUTTER_TARGET_PLATFORM "windows-x64")
endif()

# === Flutter Library ===
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")

Expand Down Expand Up @@ -91,7 +96,7 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
windows-x64 $<CONFIG>
${FLUTTER_TARGET_PLATFORM} $<CONFIG>
VERBATIM
)
add_custom_target(flutter_assemble DEPENDS
Expand Down
10 changes: 5 additions & 5 deletions example/windows/runner/Runner.rc
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ IDI_APP_ICON ICON "resources\\app_icon.ico"
// Version
//

#ifdef FLUTTER_BUILD_NUMBER
#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
#else
#define VERSION_AS_NUMBER 1,0,0
#define VERSION_AS_NUMBER 1,0,0,0
#endif

#ifdef FLUTTER_BUILD_NAME
#define VERSION_AS_STRING #FLUTTER_BUILD_NAME
#if defined(FLUTTER_VERSION)
#define VERSION_AS_STRING FLUTTER_VERSION
#else
#define VERSION_AS_STRING "1.0.0"
#endif
Expand Down

0 comments on commit 6eca4e9

Please sign in to comment.