-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 533ab2a
Showing
16 changed files
with
573 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# 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/ | ||
|
||
# Android related | ||
**/android/**/gradle-wrapper.jar | ||
**/android/.gradle | ||
**/android/captures/ | ||
**/android/gradlew | ||
**/android/gradlew.bat | ||
**/android/local.properties | ||
**/android/**/GeneratedPluginRegistrant.java | ||
|
||
# iOS/XCode related | ||
**/ios/**/*.mode1v3 | ||
**/ios/**/*.mode2v3 | ||
**/ios/**/*.moved-aside | ||
**/ios/**/*.pbxuser | ||
**/ios/**/*.perspectivev3 | ||
**/ios/**/*sync/ | ||
**/ios/**/.sconsign.dblite | ||
**/ios/**/.tags* | ||
**/ios/**/.vagrant/ | ||
**/ios/**/DerivedData/ | ||
**/ios/**/Icon? | ||
**/ios/**/Pods/ | ||
**/ios/**/.symlinks/ | ||
**/ios/**/profile | ||
**/ios/**/xcuserdata | ||
**/ios/.generated/ | ||
**/ios/Flutter/App.framework | ||
**/ios/Flutter/Flutter.framework | ||
**/ios/Flutter/Flutter.podspec | ||
**/ios/Flutter/Generated.xcconfig | ||
**/ios/Flutter/app.flx | ||
**/ios/Flutter/app.zip | ||
**/ios/Flutter/flutter_assets/ | ||
**/ios/Flutter/flutter_export_environment.sh | ||
**/ios/ServiceDefinitions.json | ||
**/ios/Runner/GeneratedPluginRegistrant.* | ||
|
||
# Exceptions to above rules. | ||
!**/ios/**/default.mode1v3 | ||
!**/ios/**/default.mode2v3 | ||
!**/ios/**/default.pbxuser | ||
!**/ios/**/default.perspectivev3 | ||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 27321ebbad34b0a3fafe99fac037102196d655ff | ||
channel: stable | ||
|
||
project_type: package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## [0.0.1] - TODO: Add release date. | ||
|
||
* TODO: Describe initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TODO: Add your license here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
![Clay Containers for implementing beautiful, modern neumorphic designs.](./example_images/banner.png) | ||
|
||
# Clay Containers | ||
|
||
Easily create and customize beautiful, modern neumorphic containers for your Flutter project. These clay containers can become the basis for your own unique neumorphic designs. | ||
|
||
## Installation | ||
|
||
Add `clay_containers` to your project as a [dependency in your pubspec.yaml file](https://flutter.dev/docs/development/packages-and-plugins/using-packages). This is a simple Dart plugin, so additional configuration for iOS and Android is not needed. | ||
|
||
## Examples | ||
|
||
### Simple `ClayContainer` | ||
For best results, set the background | ||
color of a surrounding Widget to match | ||
the color you will set for your clay | ||
container. Since it is likely you'll reuse this base color | ||
multiple times (especially if you end up doing something fancy) | ||
it's good to set this color to a single value. In the following example it | ||
is set to `baseColor`. | ||
|
||
``` | ||
import 'package:clay_containers/clay_containers.dart'; | ||
class MyExampleScreen extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
Color baseColor = Color(0xFFF2F2F2); | ||
return Container( | ||
color: baseColor, | ||
child: Center( | ||
child: ClayContainer( | ||
color: baseColor, | ||
height: 200, | ||
width: 200, | ||
), | ||
), | ||
); | ||
} | ||
} | ||
``` | ||
|
||
![ClayContainer example.](./example_images/simple.png) | ||
|
||
### `ClayContainer` with Child | ||
|
||
In the previous example the `ClayContainer` was given `height` and `width` | ||
since it has no child. | ||
`ClayContainer` behaves the same as a normal | ||
`Container` and needs to be either given `height` and `width` or a `child` to be visible. I've also included `Padding` so that the text didn't end up flesh with the edge of the container. | ||
|
||
``` | ||
ClayContainer( | ||
color: baseColor, | ||
child: Padding( | ||
padding: EdgeInsets.all(20), | ||
child: Text( | ||
"Seize the Clay!", | ||
style: TextStyle( | ||
fontSize: 40, | ||
fontWeight: FontWeight.w200, | ||
color: Colors.black45, | ||
), | ||
), | ||
), | ||
), | ||
``` | ||
|
||
![Clay container example with child.](./example_images/simple_child.png) | ||
|
||
### Rounded `ClayContainer`s | ||
|
||
Don't be a square! Use borderRadius to add some flare. If you want a uniform `borderRadius` you can simple set it directly in the `ClayContainer` constructor. | ||
|
||
``` | ||
ClayContainer( | ||
color: baseColor, | ||
height: 150, | ||
width: 150, | ||
borderRadius: 75, | ||
), | ||
``` | ||
![A rounded ClayContainer.](./example_images/circle.png) | ||
|
||
If you want to pass your own custom `BorderRadius` object, that is available as well: In that case pass it to `customBorderRadius`. | ||
|
||
``` | ||
ClayContainer( | ||
color: baseColor, | ||
height: 150, | ||
width: 150, | ||
customBorderRadius: BorderRadius.only( | ||
topRight: Radius.elliptical(150, 150), | ||
bottomLeft: Radius.circular(50)), | ||
), | ||
``` | ||
![A weird shaped ClayContainer.](./example_images/weird.png) | ||
|
||
### Change Default Spread and Depth | ||
|
||
Don't like the default look of the neumorphic effect? Change the base variables. Do whatever you want. I'm not your mom. | ||
|
||
``` | ||
ClayContainer( | ||
color: baseColor, | ||
height: 150, | ||
width: 150, | ||
borderRadius: 75, | ||
depth: 40, | ||
spread: 40, | ||
), | ||
``` | ||
![A ClayContainer as deep as a freshmen Philosophy class.](./example_images/deep.png) | ||
|
||
### Concave and Convex `ClayContainer`s | ||
|
||
Give your `ClayContainer` a convex or a concave look by passing either `CurveType.concave` or `CurveType.convex` to the `curveType` parameter. | ||
|
||
``` | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
ClayContainer( | ||
color: baseColor, | ||
height: 150, | ||
width: 150, | ||
borderRadius: 75, | ||
curveType: CurveType.concave, | ||
), | ||
SizedBox(width: 50), | ||
ClayContainer( | ||
color: baseColor, | ||
height: 150, | ||
width: 150, | ||
borderRadius: 75, | ||
curveType: CurveType.none, | ||
), | ||
SizedBox(width: 50), | ||
ClayContainer( | ||
color: baseColor, | ||
height: 150, | ||
width: 150, | ||
borderRadius: 75, | ||
curveType: CurveType.convex, | ||
), | ||
], | ||
), | ||
``` | ||
![Concave, flat, and convex ClayContainers.](./example_images/concave_convex.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
library neumorphic_containers; | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
class ClayContainer extends StatelessWidget { | ||
final double height; | ||
final double width; | ||
final Color color; | ||
final double spread; | ||
final Widget child; | ||
final double borderRadius; | ||
final BorderRadius customBorderRadius; | ||
final CurveType curveType; | ||
final int depth; | ||
|
||
ClayContainer( | ||
{this.child, this.height, this.width, @required this.color, this.spread, this.borderRadius, this.customBorderRadius, this.curveType, this.depth}); | ||
|
||
Color _getAdjustColor(Color baseColor, amount) { | ||
Map colors = { | ||
"red": baseColor.red, "green": baseColor.green, "blue": baseColor.blue | ||
}; | ||
colors = colors.map((key, value) { | ||
int result = 0; | ||
if (value + amount < 0) return MapEntry(key, 0); | ||
if (value + amount > 255) return MapEntry(key, 255); | ||
return MapEntry(key, value + amount); | ||
}); | ||
return Color.fromRGBO(colors["red"], colors["green"], colors["blue"], 1); | ||
} | ||
|
||
List<Color> _getFlatGradients(baseColor, depth) { | ||
return [ | ||
baseColor, | ||
baseColor, | ||
]; | ||
} | ||
|
||
List<Color> _getConcaveGradients(baseColor, depth) { | ||
return [ | ||
_getAdjustColor(baseColor, 0 - depth), | ||
_getAdjustColor(baseColor, depth), | ||
]; | ||
} | ||
|
||
List<Color> _getConvexGradients(baseColor, depth) { | ||
return [ | ||
_getAdjustColor(baseColor, depth), | ||
_getAdjustColor(baseColor, 0 - depth), | ||
]; | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final double heightValue = height == null ? null : height; | ||
final double widthValue = width == null ? null : width; | ||
final int depthValue = depth == null ? 20 : depth; | ||
final Color colorValue = color; | ||
final double spreadValue = spread == null ? 6 : spread; | ||
BorderRadius borderRadiusValue = borderRadius == null | ||
? BorderRadius.zero | ||
: BorderRadius.circular(borderRadius); | ||
|
||
if (customBorderRadius != null) { | ||
borderRadiusValue = customBorderRadius; | ||
} | ||
final CurveType curveTypeValue = curveType == null | ||
? CurveType.none | ||
: curveType; | ||
|
||
List<Color> gradientColors; | ||
switch (curveTypeValue) { | ||
case CurveType.concave: | ||
gradientColors = _getConcaveGradients(colorValue, depthValue); | ||
break; | ||
case CurveType.convex: | ||
gradientColors = _getConvexGradients(colorValue, depthValue); | ||
break; | ||
case CurveType.none: | ||
gradientColors = _getFlatGradients(colorValue, depthValue); | ||
break; | ||
} | ||
|
||
|
||
return Container( | ||
height: heightValue, | ||
width: widthValue, | ||
child: child, | ||
decoration: BoxDecoration( | ||
borderRadius: borderRadiusValue, | ||
color: colorValue, | ||
gradient: LinearGradient( | ||
begin: Alignment.topLeft, | ||
end: Alignment.bottomRight, | ||
colors: gradientColors), | ||
boxShadow: [ | ||
BoxShadow( | ||
color: _getAdjustColor(colorValue, depthValue), | ||
offset: Offset(0 - spreadValue, 0 - spreadValue), | ||
blurRadius: spreadValue), | ||
BoxShadow( | ||
color: _getAdjustColor(colorValue, 0 - depthValue), | ||
offset: Offset(spreadValue, spreadValue), | ||
blurRadius: spreadValue) | ||
] | ||
), | ||
); | ||
} | ||
} | ||
|
||
enum CurveType { | ||
concave, | ||
convex, | ||
none | ||
} |
Oops, something went wrong.