Skip to content

Commit

Permalink
Merge pull request #4 from note11g/feature/#2
Browse files Browse the repository at this point in the history
Impl: impl #2
  • Loading branch information
note11g authored Oct 17, 2024
2 parents 1360767 + 3e9b436 commit d2ced9d
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 22 deletions.
2 changes: 1 addition & 1 deletion example/macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C80D4294CF70F00263BE5 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion example/macos/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Cocoa
import FlutterMacOS

@NSApplicationMain
@main
class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
Expand Down
56 changes: 40 additions & 16 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,30 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev"
source: hosted
version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev"
source: hosted
version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
lints:
dependency: transitive
description:
Expand All @@ -86,34 +110,34 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.16"
version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.15.0"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
version: "1.9.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -163,10 +187,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.7.2"
vector_math:
dependency: transitive
description:
Expand All @@ -175,14 +199,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
web:
vm_service:
dependency: transitive
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
name: vm_service
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "0.3.0"
version: "14.2.5"
sdks:
dart: ">=3.2.6 <4.0.0"
flutter: ">=3.10.0"
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
22 changes: 20 additions & 2 deletions lib/balloon_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@ import 'package:flutter/material.dart';

enum BalloonNipPosition {
topLeft,
topCenter,
topRight,
bottomLeft,
bottomCenter,
bottomRight;

bool get isTop =>
this == BalloonNipPosition.topLeft || this == BalloonNipPosition.topRight;
this == BalloonNipPosition.topLeft ||
this == BalloonNipPosition.topRight ||
this == BalloonNipPosition.topCenter;

bool get isStart =>
this == BalloonNipPosition.topLeft ||
this == BalloonNipPosition.bottomRight;

bool get isCenter =>
this == BalloonNipPosition.topCenter ||
this == BalloonNipPosition.bottomCenter;
}

class Balloon extends StatelessWidget {
Expand All @@ -25,6 +33,12 @@ class Balloon extends StatelessWidget {
final Color shadowColor;
final BalloonNipPosition nipPosition;
final double nipSize;

/// The margin between the nip and the edge of the balloon. (start point is rounded end point)
///
/// if nipPosition is `topCenter` or `bottomCenter`, this value is ignored.
///
/// The default value is 4.0.
final double nipMargin;
final double nipRadius;
final bool isHeightIncludingNip;
Expand Down Expand Up @@ -249,7 +263,11 @@ extension _BalloonPathExtension on Path {
final radiusWidth = (nipRadius * math.sqrt(2) / 2);

final double nipStartX, nipEndX;
if (nipPosition.isStart) {
if (nipPosition.isCenter) {
final centerX = (start.dx + end.dx) / 2;
nipStartX = centerX - (nipWidthCenter * xDir);
nipEndX = centerX + (nipWidthCenter * xDir);
} else if (nipPosition.isStart) {
nipStartX = start.dx + (nipMargin * xDir);
nipEndX = nipStartX + (nipSize * xDir);
} else {
Expand Down
Binary file modified test/goldens/borderRadius_balloon_color_grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/include_nip_height_grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/inner_padding_grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/nip_position_grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/nip_target_position_grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/shadow_grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ void main() {
await loadAppFonts();

const textWidget = Text("Hello Flutter!");
final builder = GoldenBuilder.grid(columns: 2, widthToHeightRatio: 1)
final builder = GoldenBuilder.grid(columns: 3, widthToHeightRatio: 1)
..addScenario(
'nipPosition: topLeft',
const Balloon(
nipPosition: BalloonNipPosition.topLeft, child: textWidget))
..addScenario(
"nipPosition: topCenter",
const Balloon(
nipPosition: BalloonNipPosition.topCenter, child: textWidget))
..addScenario(
'nipPosition: topRight',
const Balloon(
Expand All @@ -20,6 +24,10 @@ void main() {
'nipPosition: bottomLeft',
const Balloon(
nipPosition: BalloonNipPosition.bottomLeft, child: textWidget))
..addScenario(
"nipPosition: bottomCenter",
const Balloon(
nipPosition: BalloonNipPosition.bottomCenter, child: textWidget))
..addScenario(
'nipPosition: bottomRight (default)',
const Balloon(
Expand Down

0 comments on commit d2ced9d

Please sign in to comment.