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

Update docs #161

Merged
merged 3 commits into from
Aug 18, 2024
Merged
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
20 changes: 12 additions & 8 deletions .github/workflows/forui_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ jobs:
defaults:
run:
working-directory: forui

strategy:
matrix:
flutter-version: [ 3.22.x, 3.x ]
steps:
- uses: actions/checkout@v4
- uses: subosito/[email protected]
with:
flutter-version: ${{ vars.ACTUALLY_WORKING_FLUTTER_VERSION }}
flutter-version: ${{ matrix.flutter-version }}
cache: true
- run: flutter pub get
- run: flutter pub run build_runner build --delete-conflicting-outputs
Expand All @@ -32,6 +34,9 @@ jobs:
build-android:
name: Build Android
runs-on: ubuntu-latest
strategy:
matrix:
flutter-version: [ 3.22.x, 3.x ]
defaults:
run:
working-directory: forui/example
Expand All @@ -43,13 +48,11 @@ jobs:
java-version: 17
- uses: subosito/[email protected]
with:
flutter-version: ${{ vars.ACTUALLY_WORKING_FLUTTER_VERSION }}
flutter-version: ${{ matrix.flutter-version }}
cache: true

- run: flutter pub get
- run: flutter pub run build_runner build --delete-conflicting-outputs
- run: flutter analyze
- run: flutter test
- run: flutter build appbundle --debug --no-pub --no-tree-shake-icons

build-ios:
Expand All @@ -58,17 +61,18 @@ jobs:
defaults:
run:
working-directory: forui/example
strategy:
matrix:
flutter-version: [ 3.22.x, 3.x ]
steps:
- uses: actions/checkout@v4
- uses: subosito/[email protected]
with:
flutter-version: ${{ vars.ACTUALLY_WORKING_FLUTTER_VERSION }}
flutter-version: ${{ matrix.flutter-version }}
cache: true

- run: flutter pub get
- run: flutter pub run build_runner build --delete-conflicting-outputs
- run: flutter analyze
- run: flutter test
- run: pod repo update
working-directory: forui/example/ios
- run: flutter build ios --debug --no-codesign --no-pub
1 change: 0 additions & 1 deletion .github/workflows/forui_presubmit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:

- uses: subosito/[email protected]
with:
flutter-version: ${{ vars.ACTUALLY_WORKING_FLUTTER_VERSION }}
cache: true

- run: flutter pub get
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/samples_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ jobs:
defaults:
run:
working-directory: samples

strategy:
matrix:
flutter-version: [ 3.22.x, 3.x ]
steps:
- uses: actions/checkout@v4
- uses: subosito/[email protected]
with:
flutter-version: ${{ vars.ACTUALLY_WORKING_FLUTTER_VERSION }}
flutter-version: ${{ matrix.flutter-version }}
cache: true
- run: flutter pub get
- run: flutter pub run build_runner build --delete-conflicting-outputs
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/samples_presubmit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:

- uses: subosito/[email protected]
with:
flutter-version: ${{ vars.ACTUALLY_WORKING_FLUTTER_VERSION }}
cache: true

- run: flutter pub get
Expand Down
15 changes: 11 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,27 @@ constitute a breaking change.
✅ Prefer this:
```dart
class Foo extends StatelessWidget {
final int _someKnobWeDontKnowIfUsefulToUsers = ...;
final int _someKnobWeDontKnowIfUsefulToUsers = 42;

const Foo() {}

@override
void build(BuildContext context) {
...
return Placeholder();
}
}
```

❌ Instead of:
```dart
class Foo extends StatelessWidget {
final int someKnobWeDontKnowIfUsefulToUsers = ...;
final int someKnobWeDontKnowIfUsefulToUsers = 42;

const Foo(this.someKnobWeDontKnowIfUsefulToUsers) {}

@override
void build(BuildContext context) {
...
return Placeholder();
}
}
```
Expand All @@ -103,6 +103,10 @@ Subclasses can interact with Forui in unforeseen ways, and cause potential issue
classes as `final`, and subsequently unmark it. The inverse isn't true. Favor composition over inheritance.


### Minimize dependency on Cupertino/Material

Cupertino and Material specific widgets should be avoided when possible.

### Minimize dependency on 3rd party packages

3rd party packages introduce uncertainty. It is difficult to predict whether a package will be maintained in the future.
Expand Down Expand Up @@ -155,13 +159,16 @@ They should:
4. override [debugFillProperties](https://api.flutter.dev/flutter/foundation/Diagnosticable/debugFillProperties.html).
5. implement `operator ==` and `hashCode`.

Lastly, the order of the fields and methods should be as shown above.

## Writing Golden Tests

Golden images are generated in the `test/golden` directory instead of relative to the test file.

Only the `Inter` font is loaded by default.

### Configuring Golden Test Threshold

By default, `matchesGoldenFile(...)` has a 0.5% threshold. In other words, images that differ by 0.5% or less will be
considered a match. Due to how different platforms render the images differently, this threshold may need to be adjusted.

Expand Down
2 changes: 2 additions & 0 deletions forui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

* Change `FResizable` to resize by `FResizable.resizePercentage` when using a keyboard.

* **Breaking:** Change `FResiableDividerStyle.thickness` to `FResizableDividerStyle.width`.

* Change `FTextFieldStyle` to inherit from `FFormFieldStyle`.

* Change `FTextField` to display error under description instead of replacing it.
Expand Down
31 changes: 3 additions & 28 deletions forui/lib/src/widgets/divider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,6 @@ final class FDividerStyles with Diagnosticable {
);

/// Returns a copy of this [FDividerStyles] with the given properties replaced.
///
/// ```dart
/// final style = FDividerStyles(
/// horizontal: ...,
/// vertical: ...,
/// );
///
/// final copy = style.copyWith(vertical: ...);
///
/// print(style.horizontal == copy.horizontal); // true
/// print(style.vertical == copy.vertical); // false
/// ```
@useResult
FDividerStyles copyWith({FDividerStyle? horizontal, FDividerStyle? vertical}) => FDividerStyles(
horizontal: horizontal ?? this.horizontal,
Expand Down Expand Up @@ -126,13 +114,13 @@ final class FDividerStyle with Diagnosticable {
///
/// ## Contract
/// Throws [AssertionError] if:
/// * `thickness` <= 0.0
/// * `thickness` is Nan
/// * `width` <= 0.0
/// * `width` is Nan
final double width;

/// Creates a [FDividerStyle].
FDividerStyle({required this.color, required this.padding, this.width = 1})
: assert(0 < width, 'The thickness is $width, but it should be in the range "0 < thickness".');
: assert(0 < width, 'The width is $width, but it should be in the range "0 < width".');

/// Creates a [FDividerStyle] that inherits its properties from [colorScheme], [style], and [padding].
FDividerStyle.inherit({
Expand All @@ -142,19 +130,6 @@ final class FDividerStyle with Diagnosticable {
}) : this(color: colorScheme.secondary, padding: padding, width: style.borderWidth);

/// Returns a copy of this [FDividerStyle] with the given properties replaced.
///
/// ```dart
/// final style = FDividerStyle(
/// color: Colors.black,
/// width: 1,
/// // Other arguments omitted for brevity
/// );
///
/// final copy = style.copyWith(width: 2);
///
/// print(copy.color); // black
/// print(copy.width); // 2
/// ```
@useResult
FDividerStyle copyWith({Color? color, EdgeInsetsGeometry? padding, double? width}) => FDividerStyle(
color: color ?? this.color,
Expand Down
36 changes: 12 additions & 24 deletions forui/lib/src/widgets/resizable/divider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class HorizontalDivider extends Divider {
color: style.color,
child: SizedBox(
height: crossAxisExtent,
width: style.thickness,
width: style.width,
),
),
if (type == FResizableDivider.dividerWithThumb)
Expand Down Expand Up @@ -172,7 +172,7 @@ class VerticalDivider extends Divider {
ColoredBox(
color: style.color,
child: SizedBox(
height: style.thickness,
height: style.width,
width: crossAxisExtent,
),
),
Expand Down Expand Up @@ -247,11 +247,11 @@ final class FResizableDividerStyle with Diagnosticable {
/// The divider's color.
final Color color;

/// The divider's thickness. Defaults to `0.5`.
/// The divider's width (thickness). Defaults to `0.5`.
///
/// ## Contract
/// Throws [AssertionError] if [thickness] <= 0.
final double thickness;
/// Throws [AssertionError] if [width] <= 0.
final double width;

/// The divider thumb's style.
final FResizableDividerThumbStyle thumbStyle;
Expand All @@ -260,31 +260,19 @@ final class FResizableDividerStyle with Diagnosticable {
FResizableDividerStyle({
required this.color,
required this.thumbStyle,
this.thickness = 0.5,
}) : assert(0 < thickness, 'Thickness should be positive, but is $thickness.');
this.width = 0.5,
}) : assert(0 < width, 'Thickness should be positive, but is $width.');

/// Returns a copy of this but with the given fields replaced with the new values.
///
/// ```dart
/// final style = FResizableDividerStyle(
/// color: ...,
/// thickness: ...,
/// );
///
/// final copy = style.copyWith(thickness: ...);
///
/// print(style.color == copy.color); // true
/// print(style.thickness == copy.thickness); // false
/// ```
@useResult
FResizableDividerStyle copyWith({
Color? color,
double? thickness,
double? width,
FResizableDividerThumbStyle? thumbStyle,
}) =>
FResizableDividerStyle(
color: color ?? this.color,
thickness: thickness ?? this.thickness,
width: width ?? this.width,
thumbStyle: thumbStyle ?? this.thumbStyle,
);

Expand All @@ -293,7 +281,7 @@ final class FResizableDividerStyle with Diagnosticable {
super.debugFillProperties(properties);
properties
..add(ColorProperty('color', color))
..add(DoubleProperty('thickness', thickness))
..add(DoubleProperty('width', width))
..add(DiagnosticsProperty('thumbStyle', thumbStyle));
}

Expand All @@ -303,11 +291,11 @@ final class FResizableDividerStyle with Diagnosticable {
other is FResizableDividerStyle &&
runtimeType == other.runtimeType &&
color == other.color &&
thickness == other.thickness &&
width == other.width &&
thumbStyle == other.thumbStyle;

@override
int get hashCode => color.hashCode ^ thickness.hashCode ^ thumbStyle.hashCode;
int get hashCode => color.hashCode ^ width.hashCode ^ thumbStyle.hashCode;
}

/// The style of the dividers' thumbs between [FResizableRegion]s.
Expand Down
2 changes: 1 addition & 1 deletion forui/test/src/widgets/resizable/divider_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'divider_test.mocks.dart';
void main() {
final style = FResizableDividerStyle(
color: const Color(0xFF000000),
thickness: 2,
width: 2,
thumbStyle: FResizableDividerThumbStyle(
backgroundColor: const Color(0xFF000000),
foregroundColor: const Color(0xFF000000),
Expand Down