Skip to content

Commit

Permalink
Let's fly!
Browse files Browse the repository at this point in the history
  • Loading branch information
trevordunn committed Jul 7, 2020
1 parent 50dede8 commit bd0f4a7
Show file tree
Hide file tree
Showing 460 changed files with 20,771 additions and 1 deletion.
49 changes: 49 additions & 0 deletions .gitignore
@@ -0,0 +1,49 @@
# 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/

# Desktop & Web related
**/GeneratedPlugins.props
**/generated_plugin_registrant.cc
**/generated_plugins.mk
**/generated_plugin_registrant.dart

# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

# Sample data
sample_data
spikes/contacts_creator/*.csv

# Firebase
/.firebase
.firebaserc
firebase.json
9 changes: 9 additions & 0 deletions LICENSE.md
@@ -0,0 +1,9 @@
Copyright 2020 gskinner.com, inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
84 changes: 83 additions & 1 deletion README.md
@@ -1 +1,83 @@
Chirp?
# Flokk
A fresh and modern Google Contacts manager that integrates with GitHub and Twitter.

## Demo Builds
- Web: https://flokk.app
- Linux: https://snapcraft.io/flokk-contacts
- macOS: https://flokk.app/macos/Flokk_Contacts_v1.0.1.dmg
- Windows: https://flokk.app/windows/Flokk_Contacts_v1.0.1.zip

## Getting Set Up

### 1. Flutter

- Follow the install instructions here: https://flutter.dev/docs/get-started/install
- Desktop-specific info: https://flutter.dev/desktop, https://github.com/flutter/flutter/wiki/Desktop-shells
- Flokk was built on the bleeding edge of Flutter, so make sure to use their the `master` branch in their git repo and checkout commit `9c3f0faa6d`.
- We're aiming to upgrade to an official Flutter version soon to make this easier.

### 2. Add Required API Keys

Google Sign In is required in order to run the app (unless running with [cached data](#running-with-cached-data)). You will need to provide your own Google API keys in the `/lib/api_keys.dart` file. Follow the instructions here to create them:
- https://developers.google.com/people/v1/how-tos/authorizing#APIKey

To optionally fetch social data for your contacts, add your own API keys for those as well:
- Twitter: https://developer.twitter.com/en/docs/basics/getting-started
- GitHub: https://developer.github.com/v3/guides/basics-of-authentication/

Although the Twitter and GitHub keys are optional, they are recommended. Otherwise the app will not be able to fetch tweets and GitHub calls will be subject to a rate limit (https://developer.github.com/v3/#rate-limiting).

### Web Builds
If you're building for web:
- Edit `/web/index.html` to include your web credentials (web client Id) `<meta name="google-signin-client_id" content="YOUR_GOOGLE_SIGN_IN_OAUTH_CLIENT_ID.apps.googleusercontent.com">`.
- This is needed for Google Sign In to work on web builds. For more details, see https://pub.dev/packages/google_sign_in_web

#### CORS Proxy
For Twitter support to work on web builds, it is necessary to use a CORS proxy. You can set up a proxy on your own domain, or else run a localhost instance with `proxy/app.js`.

If setting up on your domain, ensure you have enabled https (https://letsencrypt.org/). Once you have the security certificate, edit `proxy/app.js` and insert your cert and key. This is not necessary if running a localhost instance.

After the proxy is set up, edit `services/twitter_rest_service.dart` to point to your running proxy instance (e.g. "https://my-proxy.com", "http://localhost", etc.)

For more information, see https://github.com/Rob--W/cors-anywhere

## Running With Cached Data
If you simply want to see the app running, it is possible to run the app using cached data:
- Run the app at least once, to create your data folders
- Extract the _contents_ of /sample_data.zip to the newly created data folder on your machine:
- Windows: \Users\\[USER]\AppData\Roaming\Flokk Contacts
- Linux: $HOME/.local/share/flokk-contacts
- macOS: /Users/[USER]/Library/Containers/app.flokk/Data/Library/Application Support/app.flokk
- Overwrite any files that are there
- Launch the app again, it should now sign in, and load with existing data.
- If you sign out, your saved data will be wiped and you will need to repeat the process.

Note: This is meant as a 'read-only' mode so you can quickly explore all the widgets and features of the app. Updates, deletes, etc are not expected to work.

## Test & Build
Debug Builds
- Use `flutter run -d DEVICE_ID` to deploy a test build
- To get a list of available DEVICE_ID, use `flutter run`
- Typical values are: `windows`, `linux`, `macos`, `chrome`
- Add `--release` to deploy an optimized build

Release Builds
- Use `flutter build PACKAGE_TYPE` to build a release package
- To get a list of available PACKAGE_TYPE, use `flutter build`
- Typical values are `windows`, `linux`, `apk`, `ios`
- In order to build the snap package one must first run `lxd init` on your system if you haven't already.
** Then execute `build.sh` to create the snap from the flutter build

Force Log In
- The app uses a `kForceWebLogin` flag to force release builds to skip the oauth screen.
- Add `--dart-define=flokk.forceWebLogin=true` to your build command to enable
- E.g. `flutter build web --dart-define=flokk.forceWebLogin=true`

## Desktop Runners
The /linux and /windows folders contain modifications and should not be upgraded to upstream without first verifying that each plugin works correctly with the new upstream code and any modifications are made.

Since the desktop runners for this project may contain modifications, upgrades should not be made without first verifying that every plugin and embedder can be upgraded and that they remain compatible after an upgrade. Hopefully this will not be as much of an issue once Flutter's desktop support becomes more mature.

--

Happy Flokking!
46 changes: 46 additions & 0 deletions flokk_src/.gitignore
@@ -0,0 +1,46 @@
# 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/
deploy/
.firebase/

# Web related
lib/generated_plugin_registrant.dart

# Generated files
lib/hidden_api_keys.dart
linux/flutter/generated_plugins.mk

# Symbolication related
app.*.symbols

# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
10 changes: 10 additions & 0 deletions flokk_src/.metadata
@@ -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: ec9813a5005f4c3e75a5a9f42ce53ae280959085
channel: master

project_type: app
13 changes: 13 additions & 0 deletions flokk_src/.vscode/launch.json
@@ -0,0 +1,13 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Flutter",
"request": "launch",
"type": "dart"
}
]
}
2 changes: 2 additions & 0 deletions flokk_src/README.md
@@ -0,0 +1,2 @@
See the README on the main git repo.

61 changes: 61 additions & 0 deletions flokk_src/analysis_options.yaml
@@ -0,0 +1,61 @@


exclude:
- "strings.dart"

analyzer:
strong-mode:
implicit-dynamic: true
implicit-casts: true
errors:
unused_import: warning
unused_local_variable: warning
dead_code: warning
enable-experiment:
- extension-methods

# Lint rules and documentation, see http://dart-lang.github.io/linter/lints
linter:
rules:
- annotate_overrides
#- avoid_unused_constructor_parameters
- await_only_futures
- camel_case_types
- cancel_subscriptions
- directives_ordering
- empty_catches
- empty_statements
- hash_and_equals
- iterable_contains_unrelated_type
- list_remove_unrelated_type
- no_adjacent_strings_in_list
- no_duplicate_case_values
#- non_constant_identifier_names
- only_throw_errors
- overridden_fields
- prefer_collection_literals
- prefer_conditional_assignment
- prefer_contains
- prefer_final_fields
#- prefer_final_locals
- prefer_initializing_formals
- prefer_interpolation_to_compose_strings
- prefer_is_empty
- prefer_is_not_empty
- prefer_typing_uninitialized_variables
- recursive_getters
- slash_for_doc_comments
- test_types_in_equals
- throw_in_finally
- type_init_formals
#- unawaited_futures
- unnecessary_brace_in_string_interps
- unnecessary_getters_setters
- unnecessary_lambdas
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_statements
- unnecessary_this
- unrelated_type_equality_checks
- use_rethrow_when_possible
- valid_regexps
Binary file added flokk_src/assets/fonts/Lato-Black.ttf
Binary file not shown.
Binary file added flokk_src/assets/fonts/Lato-Bold.ttf
Binary file not shown.
Binary file added flokk_src/assets/fonts/Lato-Light.ttf
Binary file not shown.
Binary file added flokk_src/assets/fonts/Lato-Regular.ttf
Binary file not shown.
Binary file added flokk_src/assets/fonts/Lato-Thin.ttf
Binary file not shown.
Binary file added flokk_src/assets/fonts/OpenSansEmoji.ttf
Binary file not shown.
Binary file added flokk_src/assets/fonts/Quicksand-Bold.ttf
Binary file not shown.
Binary file added flokk_src/assets/fonts/Quicksand-Light.ttf
Binary file not shown.
Binary file added flokk_src/assets/fonts/Quicksand-Medium.ttf
Binary file not shown.
Binary file added flokk_src/assets/fonts/Quicksand-Regular.ttf
Binary file not shown.
Binary file added flokk_src/assets/fonts/Quicksand-SemiBold.ttf
Binary file not shown.
Binary file added flokk_src/assets/icons/2.0x/icon-add.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-address.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-birthday.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-calendar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-close-large.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-copy.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-darkmode.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-dashboard.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-dropdown-close.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-dropdown-open.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-edit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-form-add.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-form-delete.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-label.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-lightmode.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-link.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-linkout.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-mail.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-next.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-note.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flokk_src/assets/icons/2.0x/icon-phone.png
Binary file added flokk_src/assets/icons/2.0x/icon-previous.png
Binary file added flokk_src/assets/icons/2.0x/icon-refresh.png
Binary file added flokk_src/assets/icons/2.0x/icon-relationship.png
Binary file added flokk_src/assets/icons/2.0x/icon-save.png
Binary file added flokk_src/assets/icons/2.0x/icon-search.png
Binary file added flokk_src/assets/icons/2.0x/icon-setting.png
Binary file added flokk_src/assets/icons/2.0x/icon-signout.png
Binary file added flokk_src/assets/icons/2.0x/icon-social-fork.png
Binary file added flokk_src/assets/icons/2.0x/icon-social-like.png
Binary file added flokk_src/assets/icons/2.0x/icon-social-star.png
Binary file added flokk_src/assets/icons/2.0x/icon-star-empty.png
Binary file added flokk_src/assets/icons/2.0x/icon-star-filled.png
Binary file added flokk_src/assets/icons/2.0x/icon-trash.png
Binary file added flokk_src/assets/icons/2.0x/icon-user.png
Binary file added flokk_src/assets/icons/2.0x/icon-work.png
Binary file added flokk_src/assets/icons/icon-add.png
Binary file added flokk_src/assets/icons/icon-address.png
Binary file added flokk_src/assets/icons/icon-birthday.png
Binary file added flokk_src/assets/icons/icon-calendar.png
Binary file added flokk_src/assets/icons/icon-checkbox-partial.png
Binary file added flokk_src/assets/icons/icon-checkbox-selected.png
Binary file added flokk_src/assets/icons/icon-close-large.png
Binary file added flokk_src/assets/icons/icon-copy.png
Binary file added flokk_src/assets/icons/icon-darkmode.png
Binary file added flokk_src/assets/icons/icon-dashboard.png
Binary file added flokk_src/assets/icons/icon-dropdown-close.png
Binary file added flokk_src/assets/icons/icon-dropdown-open.png
Binary file added flokk_src/assets/icons/icon-edit.png
Binary file added flokk_src/assets/icons/icon-form-add.png
Binary file added flokk_src/assets/icons/icon-form-addlabel.png
Binary file added flokk_src/assets/icons/icon-form-delete.png
Binary file added flokk_src/assets/icons/icon-github-active.png
Binary file added flokk_src/assets/icons/icon-github-empty.png
Binary file added flokk_src/assets/icons/icon-label.png
Binary file added flokk_src/assets/icons/icon-lightmode.png
Binary file added flokk_src/assets/icons/icon-link.png
Binary file added flokk_src/assets/icons/icon-linkout.png
Binary file added flokk_src/assets/icons/icon-mail.png
Binary file added flokk_src/assets/icons/icon-next.png
Binary file added flokk_src/assets/icons/icon-note.png
Binary file added flokk_src/assets/icons/icon-phone.png
Binary file added flokk_src/assets/icons/icon-previous.png
Binary file added flokk_src/assets/icons/icon-refresh.png
Binary file added flokk_src/assets/icons/icon-relationship.png
Binary file added flokk_src/assets/icons/icon-save.png
Binary file added flokk_src/assets/icons/icon-search.png
Binary file added flokk_src/assets/icons/icon-setting.png
Binary file added flokk_src/assets/icons/icon-signout.png
Binary file added flokk_src/assets/icons/icon-social-fork.png
Binary file added flokk_src/assets/icons/icon-social-like.png
Binary file added flokk_src/assets/icons/icon-social-retweet.png
Binary file added flokk_src/assets/icons/icon-social-star.png
Binary file added flokk_src/assets/icons/icon-star-empty.png
Binary file added flokk_src/assets/icons/icon-star-filled.png
Binary file added flokk_src/assets/icons/icon-trash.png
Binary file added flokk_src/assets/icons/icon-twitter-active.png
Binary file added flokk_src/assets/icons/icon-twitter-empty.png
Binary file added flokk_src/assets/icons/icon-user.png
Binary file added flokk_src/assets/icons/icon-work.png
Binary file added flokk_src/assets/images/avatars/Bear.png
Binary file added flokk_src/assets/images/avatars/Camel.png
Binary file added flokk_src/assets/images/avatars/Fox.png
Binary file added flokk_src/assets/images/avatars/Giraff.png
Binary file added flokk_src/assets/images/avatars/Monkey.png
Binary file added flokk_src/assets/images/avatars/Tiger.png
Binary file added flokk_src/assets/images/avatars/avatar_bg0.png
Binary file added flokk_src/assets/images/avatars/avatar_bg1.png
Binary file added flokk_src/assets/images/avatars/avatar_bg2.png
Binary file added flokk_src/assets/images/avatars/avatar_bg3.png
Binary file added flokk_src/assets/images/avatars/avatar_bg4.png
Binary file added flokk_src/assets/images/avatars/avatar_bg5.png
Binary file added flokk_src/assets/images/avatars/avatar_bg6.png
Binary file added flokk_src/assets/images/avatars/avatar_bg7.png
Binary file added flokk_src/assets/images/avatars/avatar_bg8.png
Binary file added flokk_src/assets/images/avatars/avatar_fg0.png
Binary file added flokk_src/assets/images/avatars/avatar_fg1.png
Binary file added flokk_src/assets/images/avatars/avatar_fg2.png
Binary file added flokk_src/assets/images/avatars/avatar_fg3.png
Binary file added flokk_src/assets/images/avatars/avatar_fg4.png
Binary file added flokk_src/assets/images/avatars/avatar_fg5.png
Binary file added flokk_src/assets/images/birds/bird-flamingo.png
Binary file added flokk_src/assets/images/birds/bird-owl.png
Binary file added flokk_src/assets/images/birds/bird-parrot.png
Binary file added flokk_src/assets/images/birds/bird-peacock.png
Binary file added flokk_src/assets/images/birds/bird-pelican.png
Binary file added flokk_src/assets/images/birds/bird-penguin.png
Binary file added flokk_src/assets/images/birds/bird-swan.png
Binary file added flokk_src/assets/images/birds/bird-toucan.png
Binary file added flokk_src/assets/images/birds/bird-woodpecker.png
Binary file added flokk_src/assets/images/empty-noresult-bg@2x.png
Binary file added flokk_src/assets/images/empty-noresult-owl@2x.png
Binary file added flokk_src/assets/images/flokk-app-logo.png
Binary file added flokk_src/assets/images/flokk-logo.png
1 change: 1 addition & 0 deletions flokk_src/assets/images/flokk-logo.svg
Binary file added flokk_src/assets/images/google-signin.png
Binary file added flokk_src/assets/images/onboarding-bg.png
Binary file added flokk_src/assets/images/onboarding-birds.png
Binary file added flokk_src/assets/images/onboarding-clouds.png
Binary file added flokk_src/assets/images/sidebar-bg.png
Binary file added flokk_src/assets/images/sidebar-logo.png
15 changes: 15 additions & 0 deletions flokk_src/lib/_internal/abstract_api_keys.dart
@@ -0,0 +1,15 @@
abstract class AbstractApiKeys {
String get googleClientId;

String get googleClientSecret;

String get googleWebClientId;

String get twitterKey;

String get twitterSecret;

String get githubKey;

String get githubSecret;
}
53 changes: 53 additions & 0 deletions flokk_src/lib/_internal/components/animated_panel.dart
@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';

/// An animated sliding container, optimized to hide it's children when closed.
class AnimatedPanel extends StatefulWidget {
final bool isClosed;
final double closedX;
final double closedY;
final double duration;
final Curve curve;
final Widget child;

const AnimatedPanel({Key key, this.isClosed, this.closedX, this.closedY, this.duration, this.curve, this.child})
: super(key: key);

@override
_AnimatedPanelState createState() => _AnimatedPanelState();
}

class _AnimatedPanelState extends State<AnimatedPanel> {
bool _isHidden = true;

@override
Widget build(BuildContext context) {
Offset closePos = Offset(widget.closedX ?? 0, widget.closedY ?? 0);
double duration = _isHidden && widget.isClosed ? 0 : widget.duration;
return TweenAnimationBuilder(
curve: widget.curve ?? Curves.easeOut,
tween: Tween<Offset>(
begin: !widget.isClosed ? Offset.zero : closePos,
end: !widget.isClosed ? Offset.zero : closePos,
),
duration: Duration(milliseconds: (duration * 1000).round()),
builder: (_, Offset value, Widget c) {
_isHidden = widget.isClosed && value == Offset(widget.closedX, widget.closedY);
return _isHidden ? Container() : Transform.translate(offset: value, child: c);
},
child: widget.child,
);
}
}

extension AnimatedPanelExtensions on Widget {
Widget animatedPanelX({double closeX, bool isClosed, double duration = .35, Curve curve}) =>
animatedPanel(closePos: Offset(closeX, 0), isClosed: isClosed, curve: curve, duration: duration);

Widget animatedPanelY({double closeY, bool isClosed, double duration = .35, Curve curve}) =>
animatedPanel(closePos: Offset(0, closeY), isClosed: isClosed, curve: curve, duration: duration);

Widget animatedPanel({Offset closePos, bool isClosed, double duration = .35, Curve curve}) {
return AnimatedPanel(
closedX: closePos.dx, closedY: closePos.dy, child: this, isClosed: isClosed, duration: duration, curve: curve);
}
}

0 comments on commit bd0f4a7

Please sign in to comment.