Skip to content

Commit

Permalink
Add initial rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Pante committed Dec 7, 2024
1 parent d9ac683 commit 716b380
Show file tree
Hide file tree
Showing 41 changed files with 698 additions and 118 deletions.
4 changes: 2 additions & 2 deletions docs/pages/docs/form/slider.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ An input where the user selects a value from within a given range.

```dart
FSlider(
layout: Layout.rtl,
layout: FLayout.rtl,
tooltipBuilder: (style, value) => Text('${(value.toStringAsFixed(2)}%'),
controller: FContinuousSliderController(
allowedInteraction: FSliderInteraction.tap,
Expand Down Expand Up @@ -231,7 +231,7 @@ describes the mark's value.
FSlider(
label: const Text('Volume'),
description: const Text('Adjust the volume by dragging the slider.'),
layout: Layout.btt,
layout: FLayout.btt,
controller: FContinuousSliderController(selection: FSliderSelection(max: 0.35)),
trackMainAxisExtent: 350,
marks: const [
Expand Down
1 change: 1 addition & 0 deletions forui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ build/
test/golden/failures/
test/**/*_test.mocks.dart
/.temp/
custom_lint.log
4 changes: 4 additions & 0 deletions forui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@

* Change `FSelectMenuTile` to be scrollable.

* Change `ThemeBuildContext` to `FThemeBuildContext`.

* **Breaking** Change `Layout` to `FLayout`.

* **Breaking** Change `FTileData.index` to `FTileData.last`.

* **Breaking** Change `FPopoverMenu.controller` to `FPopoverMenu.popoverController`.
Expand Down
42 changes: 2 additions & 40 deletions forui/README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,3 @@
<a href="https://forui.dev">
<h1 align="center">
<img width="400" alt="Forui" src="https://raw.githubusercontent.com/forus-labs/forui/main/docs/public/light_logo.png">
</h1>
</a>
# Forui Internal Lints

<p align="center">
<a href="https://github.com/forus-labs/forui/actions/workflows/forui_build.yaml"><img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/forus-labs/forui/forui_build.yaml?branch=main&style=flat&logo=github&label=main"></a>
<a href="https://pub.dev/packages/forui"><img alt="Pub Version" src="https://img.shields.io/pub/v/forui?style=flat&logo=dart&label=pub.dev&color=00589B"></a>
<a href="https://github.com/forus-labs/forui"><img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/forus-labs/forui?style=flat&logo=github&color=8957e5&link=https%3A%2F%2Fgithub.com%2Fforus-labs%2Fforui"></a>
<a href="https://github.com/forus-labs/forui"><img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/forus-labs/forui?style=flat&logo=github"></a>
<a href="https://discord.gg/jrw3qHksjE"><img alt="Discord" src="https://img.shields.io/discord/1268920771062009886?logo=discord&logoColor=fff&label=discord&color=%237289da"></a>
</p>

<p align="center">
<a href="https://forui.dev/docs">📚 Documentation</a> •
<a href="https://forui.dev/docs/layout/divider">🖼️ Widgets</a> •
<a href="https://pub.dev/documentation/forui">🤓 API Reference</a> •
<a href="https://github.com/orgs/forus-labs/projects/9">🗺️ Road Map</a>
</p>

<p align="center">
Forui is a Flutter UI library that provides a set of beautifully designed, minimalistic widgets.
</p>

<br />
<div align="center">
<img width="800" alt="Forui" src="https://raw.githubusercontent.com/forus-labs/forui/main/docs/public/banner-160724.png">
</div>

## Documentation

Visit [forui.dev/docs](https://forui.dev/docs) to view the documentation.

## Contributing

Please read the [contributing guide](https://github.com/forus-labs/forui/blob/main/CONTRIBUTING.md).

## License

Licensed under the [MIT License](https://github.com/forus-labs/forui/blob/main/forui/LICENSE) and [Open Font License](https://github.com/forus-labs/forui/blob/main/forui/LICENSE).
Internal Lints used by the Forui project. Not intended for public use.
4 changes: 3 additions & 1 deletion forui/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
include: package:flint/analysis_options.flutter.yaml
analyzer:
plugins:
- custom_lint
errors:
unused_result: ignore

linter:
rules:
- use_key_in_widget_constructors
- require_trailing_commas
- require_trailing_commas
20 changes: 10 additions & 10 deletions forui/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ packages:
dependency: transitive
description:
name: flutter_svg
sha256: "936d9c1c010d3e234d1672574636f3352b4941ca3decaddd3cafaeb9ad49c471"
sha256: "54900a1a1243f3c4a5506d853a2b5c2dbc38d5f27e52a52618a8054401431123"
url: "https://pub.dev"
source: hosted
version: "2.0.15"
version: "2.0.16"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -501,18 +501,18 @@ packages:
dependency: transitive
description:
name: path_provider_android
sha256: c464428172cb986b758c6d1724c603097febb8fb855aa265aeecc9280c294d4a
sha256: "8c4967f8b7cb46dc914e178daa29813d83ae502e0529d7b0478330616a691ef7"
url: "https://pub.dev"
source: hosted
version: "2.2.12"
version: "2.2.14"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16
sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942"
url: "https://pub.dev"
source: hosted
version: "2.4.0"
version: "2.4.1"
path_provider_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -714,10 +714,10 @@ packages:
dependency: transitive
description:
name: vector_graphics_compiler
sha256: ab9ff38fc771e9ee1139320adbe3d18a60327370c218c60752068ebee4b49ab1
sha256: "1b4b9e706a10294258727674a340ae0d6e64a7231980f9f9a3d12e4b42407aad"
url: "https://pub.dev"
source: hosted
version: "1.1.15"
version: "1.1.16"
vector_math:
dependency: transitive
description:
Expand Down Expand Up @@ -786,10 +786,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: "84ba388638ed7a8cb3445a320c8273136ab2631cd5f2c57888335504ddab1bc2"
sha256: "8b338d4486ab3fbc0ba0db9f9b4f5239b6697fcee427939a40e720cbb9ee0a69"
url: "https://pub.dev"
source: hosted
version: "5.8.0"
version: "5.9.0"
xdg_directories:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions forui/lib/src/foundation/rendering.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/rendering.dart';
import 'package:meta/meta.dart';

/// Possible way to layout a sequence of items.
enum Layout {
enum FLayout {
/// Lays out the items horizontally from left to right.
ltr(vertical: false),

Expand All @@ -19,7 +19,7 @@ enum Layout {
/// Whether the layout is vertical.
final bool vertical;

const Layout({required this.vertical});
const FLayout({required this.vertical});
}

@internal
Expand Down
6 changes: 3 additions & 3 deletions forui/lib/src/theme/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:forui/forui.dart';
/// Applies a theme to descendant widgets.
///
/// A theme configures the colors and typographic choices of Forui widgets. The actual configuration is stored in
/// a [FThemeData]. Descendant widgets obtain the current theme's [FThemeData] via either [ThemeBuildContext.theme],
/// a [FThemeData]. Descendant widgets obtain the current theme's [FThemeData] via either [FThemeBuildContext.theme],
/// or [FTheme.of]. When a widget uses either, it is automatically rebuilt if the theme later changes.
///
/// ```dart
Expand All @@ -35,7 +35,7 @@ import 'package:forui/forui.dart';
class FTheme extends StatelessWidget {
/// Returns the current [FThemeData], or `FThemes.zinc.light` if there is no ancestor [FTheme].
///
/// It is recommended to use the terser [ThemeBuildContext.theme] getter instead.
/// It is recommended to use the terser [FThemeBuildContext.theme] getter instead.
///
/// ## Troubleshooting:
///
Expand Down Expand Up @@ -141,7 +141,7 @@ class _InheritedTheme extends InheritedTheme {
}

/// Provides functions for accessing the current [FThemeData].
extension ThemeBuildContext on BuildContext {
extension FThemeBuildContext on BuildContext {
/// Returns the current [FThemeData], or `FThemes.zinc.light` if there is no ancestor [FTheme].
///
/// ## Troubleshooting:
Expand Down
2 changes: 1 addition & 1 deletion forui/lib/src/widgets/slider/inherited_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class InheritedData extends InheritedWidget {
}

final FSliderStyle style;
final Layout layout;
final FLayout layout;
final List<FSliderMark> marks;
final double? trackMainAxisExtent;
final double? trackHitRegionCrossExtent;
Expand Down
8 changes: 4 additions & 4 deletions forui/lib/src/widgets/slider/slider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class FSlider extends StatelessWidget {
final FSliderStyle? style;

/// The layout. Defaults to the current [TextDirection].
final Layout? layout;
final FLayout? layout;

/// The label.
final Widget? label;
Expand Down Expand Up @@ -158,8 +158,8 @@ class FSlider extends StatelessWidget {
final styles = context.theme.sliderStyles;
final layout = switch (this.layout) {
final layout? => layout,
_ when Directionality.maybeOf(context) == TextDirection.rtl => Layout.rtl,
_ => Layout.ltr,
_ when Directionality.maybeOf(context) == TextDirection.rtl => FLayout.rtl,
_ => FLayout.ltr,
};
final sliderStyle = style ?? (layout.vertical ? styles.verticalStyle : styles.horizontalStyle);

Expand Down Expand Up @@ -219,7 +219,7 @@ class FSlider extends StatelessWidget {
class _Slider extends StatefulWidget {
final FSliderController controller;
final FSliderStyle style;
final Layout layout;
final FLayout layout;
final Widget? label;
final Widget? description;
final Widget Function(BuildContext, String) errorBuilder;
Expand Down
2 changes: 1 addition & 1 deletion forui/lib/src/widgets/slider/slider_mark.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ final class FSliderMarkStyle with Diagnosticable {
/// The label's offset from the slider, along its cross axis, in logical pixels. The top-left corner is always the
/// origin, regardless of the layout.
///
/// For example, if the layout is [Layout.ltr] and the cross axis offset is 3, the label will be 3 pixels below the
/// For example, if the layout is [FLayout.ltr] and the cross axis offset is 3, the label will be 3 pixels below the
/// slider's edge.
///
/// ```
Expand Down
14 changes: 7 additions & 7 deletions forui/lib/src/widgets/slider/slider_render_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ abstract class _RenderSlider extends RenderBox
with ContainerRenderObjectMixin<RenderBox, _Data>, RenderBoxContainerDefaultsMixin<RenderBox, _Data> {
FSliderStyle _style;
FSliderStateStyle _stateStyle;
Layout _layout;
FLayout _layout;
List<FSliderMark> _marks;
double? _mainAxisExtent;
late Rect Function(RenderBox, Size, FSliderMark, FSliderMarkStyle) _positionMark;
Expand Down Expand Up @@ -237,22 +237,22 @@ abstract class _RenderSlider extends RenderBox
Rect Function(RenderBox, Size, FSliderMark, FSliderMarkStyle) get _position {
final insets = _style.labelLayoutStyle.childPadding;
return switch (_layout) {
Layout.ltr => (track, label, mark, style) {
FLayout.ltr => (track, label, mark, style) {
final extent = track.size.width - insets.left - insets.right;
final offset = _anchor(extent, mark.value, insets.left, insets.top, style);
return _rect(label, mark, Offset(offset.$1, offset.$2), style);
},
Layout.rtl => (track, size, mark, style) {
FLayout.rtl => (track, size, mark, style) {
final extent = track.size.width - insets.left - insets.right;
final offset = _anchor(extent, 1 - mark.value, insets.left, insets.top, style);
return _rect(size, mark, Offset(offset.$1, offset.$2), style);
},
Layout.ttb => (track, size, mark, style) {
FLayout.ttb => (track, size, mark, style) {
final extent = track.size.height - insets.top - insets.bottom;
final offset = _anchor(extent, mark.value, insets.top, insets.left, style);
return _rect(size, mark, Offset(offset.$2, offset.$1), style);
},
Layout.btt => (track, size, mark, style) {
FLayout.btt => (track, size, mark, style) {
final extent = track.size.height - insets.top - insets.bottom;
final offset = _anchor(extent, 1 - mark.value, insets.top, insets.left, style);
return _rect(size, mark, Offset(offset.$2, offset.$1), style);
Expand Down Expand Up @@ -332,9 +332,9 @@ abstract class _RenderSlider extends RenderBox
markNeedsLayout();
}

Layout get sliderLayout => _layout;
FLayout get sliderLayout => _layout;

set sliderLayout(Layout value) {
set sliderLayout(FLayout value) {
if (_layout == value) {
return;
}
Expand Down
22 changes: 11 additions & 11 deletions forui/lib/src/widgets/slider/thumb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,26 +186,26 @@ class _ThumbState extends State<Thumb> with SingleTickerProviderStateMixin {

double _offset(FSliderSelection selection) => widget.min ? selection.offset.min : selection.offset.max;

Map<ShortcutActivator, Intent> _shortcuts(Layout layout) => switch ((layout, widget.min)) {
(Layout.ltr, true) || (Layout.rtl, false) => const {
Map<ShortcutActivator, Intent> _shortcuts(FLayout layout) => switch ((layout, widget.min)) {
(FLayout.ltr, true) || (FLayout.rtl, false) => const {
SingleActivator(LogicalKeyboardKey.arrowLeft): _ExtendIntent(),
SingleActivator(LogicalKeyboardKey.arrowRight): _ShrinkIntent(),
},
(Layout.ltr, false) || (Layout.rtl, true) => const {
(FLayout.ltr, false) || (FLayout.rtl, true) => const {
SingleActivator(LogicalKeyboardKey.arrowLeft): _ShrinkIntent(),
SingleActivator(LogicalKeyboardKey.arrowRight): _ExtendIntent(),
},
(Layout.ttb, true) || (Layout.btt, false) => const {
(FLayout.ttb, true) || (FLayout.btt, false) => const {
SingleActivator(LogicalKeyboardKey.arrowUp): _ExtendIntent(),
SingleActivator(LogicalKeyboardKey.arrowDown): _ShrinkIntent(),
},
(Layout.ttb, false) || (Layout.btt, true) => const {
(FLayout.ttb, false) || (FLayout.btt, true) => const {
SingleActivator(LogicalKeyboardKey.arrowUp): _ShrinkIntent(),
SingleActivator(LogicalKeyboardKey.arrowDown): _ExtendIntent(),
},
};

GestureDragUpdateCallback? _drag(FSliderController controller, double thumbSize, Layout layout) {
GestureDragUpdateCallback? _drag(FSliderController controller, double thumbSize, FLayout layout) {
if (controller.allowedInteraction == FSliderInteraction.tap) {
return null;
}
Expand Down Expand Up @@ -297,11 +297,11 @@ final class FSliderThumbStyle with Diagnosticable {
}

@internal
extension Layouts on Layout {
extension Layouts on FLayout {
double Function(Offset) translateThumbDrag(double thumbSize) => switch (this) {
Layout.ltr => (delta) => delta.dx - thumbSize / 2,
Layout.rtl => (delta) => -delta.dx + thumbSize / 2,
Layout.ttb => (delta) => delta.dy - thumbSize / 2,
Layout.btt => (delta) => -delta.dy + thumbSize / 2,
FLayout.ltr => (delta) => delta.dx - thumbSize / 2,
FLayout.rtl => (delta) => -delta.dx + thumbSize / 2,
FLayout.ttb => (delta) => delta.dy - thumbSize / 2,
FLayout.btt => (delta) => -delta.dy + thumbSize / 2,
};
}
Loading

0 comments on commit 716b380

Please sign in to comment.