Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added availability for breakpoints customization #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
## [1.0.0] - Initial stable release
## [2.1.0]

* Initial release

## [1.0.0+1]
* Added breakpoints customization

* Code formatting
## [2.0.0]

## [1.0.0+2]
* Migrated to null-safety [thanks to anisalibegic]

* Warning suppression
## [1.0.2]

* Calculation off by 1px (md size) [thanks to gibahjoe]
* Visibility bug on small size

## [1.0.1]

* BootstrapRow.height now gives a real "min height"

## [1.0.2]
## [1.0.0+2]

* Calculation off by 1px (md size) [thanks to gibahjoe]
* Visibility bug on small size
* Warning suppression

## [2.0.0]
## [1.0.0+1]

* Migrated to null-safety [thanks to anisalibegic]
* Code formatting

## [1.0.0] - Initial stable release

* Initial release
39 changes: 31 additions & 8 deletions lib/src/flutter_bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,35 @@ List<String> _prefixesReversed = ['', 'sm', 'md', 'lg', 'xl'];
double _oneColumnRatio = 0.083333;
double _gutterSize = 48.0;
int _numberOfColumns = 12;
BootstrapGridBreakpoints _breakpoints = const BootstrapGridBreakpoints();

///
/// Grid breakpoints values
///
class BootstrapGridBreakpoints {
final double xs;
final double sm;
final double md;
final double lg;
final double xl;

const BootstrapGridBreakpoints({
this.xs = 0,
this.sm = 575,
this.md = 767,
this.lg = 992,
this.xl = 1200,
});
}


///
/// Customization of the grid
///
void bootstrapGridParameters({
int numberOfColumns = 12,
double gutterSize = 24,
BootstrapGridBreakpoints breakpoints = const BootstrapGridBreakpoints(),
}) {
assert(() {
if (numberOfColumns < 10 || numberOfColumns > 24) {
Expand All @@ -40,6 +62,7 @@ void bootstrapGridParameters({
_numberOfColumns = numberOfColumns;
_oneColumnRatio = 1.0 / numberOfColumns;
_gutterSize = gutterSize;
_breakpoints = breakpoints;
}

///
Expand All @@ -48,19 +71,19 @@ void bootstrapGridParameters({
String bootstrapPrefixBasedOnWidth(double width) {
String pfx = "";

if (width > 1200) {
if (width > _breakpoints.xl) {
return "xl";
}

if (width > 992) {
if (width > _breakpoints.lg) {
return "lg";
}

if (width > 767) {
if (width > _breakpoints.md) {
return "md";
}

if (width > 575) {
if (width > _breakpoints.sm) {
return "sm";
}

Expand All @@ -75,16 +98,16 @@ double bootstrapMaxWidthNonFluid(double width) {
///
/// Otherwise, it depends on the available width
///
if (width >= 1200) {
if (width >= _breakpoints.xl) {
return 1140;
}
if (width >= 992) {
if (width >= _breakpoints.lg) {
return 960;
}
if (width >= 768) {
if (width >= _breakpoints.lg + 1) {
return 720;
}
if (width >= 576) {
if (width >= _breakpoints.lg + 1) {
return 540;
}
return width;
Expand Down
15 changes: 11 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0"
collection:
dependency: transitive
description:
Expand All @@ -20,13 +20,20 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.7.0"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -45,6 +52,6 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.1"
sdks:
dart: ">=2.12.0 <3.0.0"
dart: ">=2.14.0 <3.0.0"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_bootstrap
description: A partial implementation of Bootstrap Grid system in Flutter for Responsive Layout.
version: 2.0.0
version: 2.1.0
homepage: https://github.com/boeledi/flutter_bootstrap

environment:
Expand Down