Skip to content

Commit

Permalink
Merge pull request #4 from touchlane/develop
Browse files Browse the repository at this point in the history
v1.0.0
  • Loading branch information
landarskiy committed Mar 3, 2024
2 parents bb89bc6 + 7eec8fd commit 9db9b6b
Show file tree
Hide file tree
Showing 17 changed files with 284 additions and 266 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# 1.0.0

* **New**: added the `fx()` and `wt()` extension functions to the `num` class to simplify the creation of `Fixed` and `Weight` cell sizes.
* **New**: added the `cell()` and `implicitCell()` extension functions to the `Widget` class to simplify the creation of `Cell` and `Cell.implicit` widgets.
* Minimum Flutter SDK is **3.0.0**

# 0.9.0

Update version
* Version update

# 0.0.9

First public release
* **New**: first public release
34 changes: 26 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ GridPad(
);
```

Instead of using `Weight` and `Fixed` explicitly, the appropriate extension functions can be used:

```dart
GridPad(
gridPadCells: GridPadCellsBuilder(rowCount: 3, columnCount: 4)
.rowSize(0, 2.wt())
.columnSize(3, 90.fx())
.build(),
children: [],
);
```

![custom_define_grid_dark](https://github.com/landarskiy/gridpad_flutter/assets/2251498/4a769913-c84d-427c-8f1b-10a1574d2bf2)

The algorithm for allocating available space between cells:
Expand Down Expand Up @@ -136,6 +148,18 @@ GridPad(
);
```

Alternatively, instead of the Cell widget, `Widget.cell()` extension functions can be applied:

```dart
GridPad(
gridPadCells: GridPadCells.gridSize(rowCount: 3, columnCount: 4),
children: [
ChildWidget().cell(row: 1, column: 2),
ChildWidget().cell(row: 0, column: 1),
],
);
```

![place_items_specific_dark](https://github.com/landarskiy/gridpad_flutter/assets/2251498/f1bf96e4-f7d2-4614-bda6-4e90ff18a741)

> :warning: A cell can contain more than one item. The draw order will be the same as the place
Expand Down Expand Up @@ -216,13 +240,7 @@ GridPad(
children: [
// will be skipped in a drawing process because the item is placed in the column range [3;5]
// but the maximum allowable is 3
Cell(
row: 1,
column: 3
rowSpan: 1,
columnSpan: 3,
child: ChildWidget(),
),
ChildWidget().cell(row: 1, column: 3, rowSpan: 1, columnSpan: 3),
],
);
```
Expand All @@ -238,7 +256,7 @@ parameter - **anchor**. The anchor is the point in the corner from which the spa
The value depends on `horizontalPolicy` and `verticalPolicy` values in the `placementPolicy`
property.

![anchor](https://github.com/landarskiy/gridpad_flutter/assets/2251498/1c7e5df7-e311-4d21-b86b-e0304c9f4069)
![anchor](https://github.com/touchlane/gridpad_flutter/assets/2251498/9ec4d525-5450-4aba-a456-3896ce553db4)

## Layout Direction

Expand Down
4 changes: 2 additions & 2 deletions example/lib/components/blueprint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import '../theme.dart';

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

@override
Widget build(BuildContext context) {
Expand All @@ -29,7 +29,7 @@ class BlueprintBox extends StatelessWidget {
class ContentBlueprintBox extends StatelessWidget {
final String text;

const ContentBlueprintBox({Key? key, this.text = ''}) : super(key: key);
const ContentBlueprintBox({super.key, this.text = ''});

@override
Widget build(BuildContext context) {
Expand Down
39 changes: 15 additions & 24 deletions example/lib/components/engineering_calculator_pad.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:grid_pad/grid_pad.dart';
import 'pad_button.dart';

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

@override
Widget build(BuildContext context) {
Expand All @@ -19,30 +19,21 @@ class EngineeringCalculatorPad extends StatelessWidget {
),
child: GridPad(
gridPadCells: GridPadCellsBuilder(rowCount: 5, columnCount: 5)
.rowSize(0, const Fixed(48))
.rowSize(0, 48.fx())
.build(),
children: [
//BG space
Cell(
row: 1,
column: 0,
rowSpan: 4,
columnSpan: 3,
child: DecoratedBox(
decoration: BoxDecoration(
color: padTheme.colors.numBackground,
shape: BoxShape.rectangle,
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
),
child: Container(),
DecoratedBox(
decoration: BoxDecoration(
color: padTheme.colors.numBackground,
shape: BoxShape.rectangle,
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
),
),
Cell(
row: 0,
column: 0,
child: _FunctionTheme(
child: SmallTextPadButton('sin', onPressed: () {})),
),
child: Container(),
).cell(row: 1, column: 0, rowSpan: 4, columnSpan: 3),
_FunctionTheme(
child: SmallTextPadButton('sin', onPressed: () {}),
).cell(row: 0, column: 0),
_FunctionTheme(child: SmallTextPadButton('cos', onPressed: () {})),
_FunctionTheme(child: SmallTextPadButton('log', onPressed: () {})),
_FunctionTheme(child: SmallTextPadButton('π', onPressed: () {})),
Expand Down Expand Up @@ -133,7 +124,7 @@ class EngineeringCalculatorPadTheme {
class _FunctionTheme extends StatelessWidget {
final Widget child;

const _FunctionTheme({Key? key, required this.child}) : super(key: key);
const _FunctionTheme({required this.child});

@override
Widget build(BuildContext context) {
Expand All @@ -153,7 +144,7 @@ class _FunctionTheme extends StatelessWidget {
class _ActionTheme extends StatelessWidget {
final Widget child;

const _ActionTheme({Key? key, required this.child}) : super(key: key);
const _ActionTheme({required this.child});

@override
Widget build(BuildContext context) {
Expand All @@ -173,7 +164,7 @@ class _ActionTheme extends StatelessWidget {
class _RemoveTheme extends StatelessWidget {
final Widget child;

const _RemoveTheme({Key? key, required this.child}) : super(key: key);
const _RemoveTheme({required this.child});

@override
Widget build(BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion example/lib/components/interactive_pin_pad.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'pin_pad.dart';

class InteractivePinPad extends StatefulWidget {
const InteractivePinPad({Key? key}) : super(key: key);
const InteractivePinPad({super.key});

@override
State<InteractivePinPad> createState() => _InteractivePinPadState();
Expand Down
23 changes: 11 additions & 12 deletions example/lib/components/pad_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class IconPadButton extends StatelessWidget {

const IconPadButton(
this.iconData, {
Key? key,
super.key,
this.onPressed,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand All @@ -31,9 +31,9 @@ class LargeTextPadButton extends StatelessWidget {

const LargeTextPadButton(
this.text, {
Key? key,
super.key,
this.onPressed,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand All @@ -51,9 +51,9 @@ class MediumTextPadButton extends StatelessWidget {

const MediumTextPadButton(
this.text, {
Key? key,
super.key,
this.onPressed,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand All @@ -71,9 +71,9 @@ class SmallTextPadButton extends StatelessWidget {

const SmallTextPadButton(
this.text, {
Key? key,
super.key,
this.onPressed,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand All @@ -91,11 +91,11 @@ class TextPadButton extends StatelessWidget {
final VoidCallback? onPressed;

const TextPadButton({
Key? key,
super.key,
required this.text,
this.style,
this.onPressed,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand All @@ -115,8 +115,7 @@ class PadButton extends StatelessWidget {
final Widget child;
final VoidCallback? onPressed;

const PadButton({Key? key, this.onPressed, required this.child})
: super(key: key);
const PadButton({super.key, this.onPressed, required this.child});

@override
Widget build(BuildContext context) {
Expand Down
14 changes: 5 additions & 9 deletions example/lib/components/pin_pad.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'pad_button.dart';
class PinPad extends StatelessWidget {
final PadActionCallback? callback;

const PinPad({Key? key, this.callback}) : super(key: key);
const PinPad({super.key, this.callback});

@override
Widget build(BuildContext context) {
Expand All @@ -25,14 +25,10 @@ class PinPad extends StatelessWidget {
verticalPolicy: VerticalPolicy.bottomTop,
),
children: [
Cell(
row: 3,
column: 1,
child: LargeTextPadButton(
'0',
onPressed: () => callback?.call('0'),
),
),
LargeTextPadButton(
'0',
onPressed: () => callback?.call('0'),
).cell(row: 3, column: 1),
PadThemeProvider(
theme: PadButtonTheme(
colors: PadButtonColors(
Expand Down
26 changes: 8 additions & 18 deletions example/lib/components/simple_calculator_pad.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:grid_pad/grid_pad.dart';
import 'pad_button.dart';

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

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -35,21 +35,11 @@ class SimpleCalculatorPad extends StatelessWidget {
LargeTextPadButton('1', onPressed: () {}),
LargeTextPadButton('2', onPressed: () {}),
LargeTextPadButton('3', onPressed: () {}),
Cell.implicit(
rowSpan: 2,
child: _ActionTheme(
child: LargeTextPadButton('=', onPressed: () {}),
),
),
Cell(
row: 4,
column: 0,
child: LargeTextPadButton('.', onPressed: () {}),
),
Cell.implicit(
columnSpan: 2,
child: LargeTextPadButton('0', onPressed: () {}),
),
_ActionTheme(
child: LargeTextPadButton('=', onPressed: () {}),
).implicitCell(rowSpan: 2),
LargeTextPadButton('.', onPressed: () {}).cell(row: 4, column: 0),
LargeTextPadButton('0', onPressed: () {}).implicitCell(columnSpan: 2),
],
),
);
Expand Down Expand Up @@ -115,7 +105,7 @@ extension _ThemeExtension on BuildContext {
class _ActionTheme extends StatelessWidget {
final Widget child;

const _ActionTheme({Key? key, required this.child}) : super(key: key);
const _ActionTheme({required this.child});

@override
Widget build(BuildContext context) {
Expand All @@ -135,7 +125,7 @@ class _ActionTheme extends StatelessWidget {
class _RemoveTheme extends StatelessWidget {
final Widget child;

const _RemoveTheme({Key? key, required this.child}) : super(key: key);
const _RemoveTheme({required this.child});

@override
Widget build(BuildContext context) {
Expand Down
Loading

0 comments on commit 9db9b6b

Please sign in to comment.