Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BakerJQ committed Oct 13, 2020
1 parent 517583b commit 1d9d0d7
Show file tree
Hide file tree
Showing 11 changed files with 764 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: f7a6a7906be96d2288f5d63a5a54c515a6e987fe
channel: unknown

project_type: package
43 changes: 43 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
10 changes: 10 additions & 0 deletions example/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: f7a6a7906be96d2288f5d63a5a54c515a6e987fe
channel: unknown

project_type: app
16 changes: 16 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# example

A new Flutter project.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
95 changes: 95 additions & 0 deletions example/lib/drop_down_menu.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import 'package:easy_popup/easy_popup.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

class DropDownMenu extends StatefulWidget with PopupChild {
final _PopController controller = _PopController();

@override
_DropDownMenuState createState() => _DropDownMenuState();

@override
dismiss() {
controller.dismiss();
}
}

class _DropDownMenuState extends State<DropDownMenu>
with SingleTickerProviderStateMixin {
Animation<Offset> _animation;
AnimationController _controller;

@override
void initState() {
super.initState();
widget.controller._bindState(this);
_controller = AnimationController(
vsync: this,
duration: Duration(milliseconds: 300),
);
_animation = Tween<Offset>(begin: Offset(0, -1), end: Offset.zero)
.animate(_controller);
_controller.forward();
}

dismiss() {
_controller?.reverse();
}

@override
void dispose() {
super.dispose();
_controller?.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Container(
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top + 50),
child: ClipRect(
child: SlideTransition(
position: _animation,
child: Container(
color: Colors.white,
child: ListView.builder(
padding: EdgeInsets.all(0),
shrinkWrap: true,
itemCount: 4,
itemExtent: 50,
itemBuilder: (context, index) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Fluttertoast.showToast(msg: 'item$index');
EasyPopup.pop(context);
},
child: Container(
alignment: Alignment.center,
child: Text(
'item$index',
),
),
);
},
),
),
),
),
),
);
}
}

class _PopController {
_DropDownMenuState state;

_bindState(_DropDownMenuState state) {
this.state = state;
}

dismiss() {
state?.dismiss();
}
}
32 changes: 32 additions & 0 deletions example/lib/highlight_popup.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:easy_popup/easy_popup.dart';
import 'package:flutter/material.dart';

class HighLightPopup extends StatelessWidget with PopupChild {
final GlobalKey highlightKey;

HighLightPopup(this.highlightKey);

@override
Widget build(BuildContext context) {
RenderBox box = highlightKey.currentContext.findRenderObject();
Offset offset = box.localToGlobal(Offset.zero);
return Scaffold(
backgroundColor: Colors.transparent,
body: Container(
padding: EdgeInsets.only(
top: offset.dy - 55,
left: offset.dx + (box.size.width - 300) / 2,
),
child: Container(
width: 300,
height: 50,
alignment: Alignment.center,
color: Colors.white,
child: Text('This is a highlight popup.')),
),
);
}

@override
dismiss() {}
}
75 changes: 75 additions & 0 deletions example/lib/home_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import 'package:easy_popup/easy_popup.dart';
import 'package:flutter/material.dart';

import 'drop_down_menu.dart';
import 'highlight_popup.dart';

class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
GlobalKey key = new GlobalKey();

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(50),
child: AppBar(
title: Text('EasyPopup'),
),
),
backgroundColor: Colors.white,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: _showDropDownMenu,
child: Container(
color: Colors.blueAccent,
alignment: Alignment.center,
width: 200,
height: 50,
child: Text(
'ShowDropDownMenu',
style: TextStyle(color: Colors.white),
),
),
),
GestureDetector(
key: key,
behavior: HitTestBehavior.opaque,
onTap: _showGuidePopup,
child: Padding(
padding: EdgeInsets.all(5),
child: Container(
width: 200,
height: 50,
color: Colors.blueAccent,
alignment: Alignment.center,
child: Text(
'ShowHighLightPopup',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
),
);
}

_showDropDownMenu() {
EasyPopup.show(context, DropDownMenu(),
offsetLT: Offset(0, MediaQuery.of(context).padding.top + 50));
}

_showGuidePopup() {
EasyPopup.show(context, HighLightPopup(key), highlightWidgetKey: key);
}
}
15 changes: 15 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:flutter/material.dart';

import 'home_page.dart';

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

class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) => MaterialApp(home: Home());
}
Loading

0 comments on commit 1d9d0d7

Please sign in to comment.