2024-12-07 12:29:34 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
2024-12-07 12:39:11 +00:00
|
|
|
/* Copyright (C) 2024 Marco Groß <mgross@sw-gross.de> */
|
2024-09-06 16:51:24 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class RectangularNotchShape extends NotchedShape {
|
|
|
|
const RectangularNotchShape();
|
|
|
|
|
|
|
|
@override
|
|
|
|
Path getOuterPath(Rect host, Rect? guest) {
|
|
|
|
if (guest == null || !host.overlaps(guest)) {
|
|
|
|
return Path()..addRect(host);
|
|
|
|
}
|
|
|
|
|
|
|
|
var margin = 20;
|
|
|
|
|
|
|
|
return Path()
|
|
|
|
..moveTo(host.left, host.top)
|
|
|
|
..lineTo(guest.left - margin, host.top)
|
|
|
|
..quadraticBezierTo(guest.left, host.top, guest.left, host.top + margin)
|
|
|
|
..lineTo(guest.left, guest.bottom - margin)
|
|
|
|
..quadraticBezierTo(
|
|
|
|
guest.left, guest.bottom, guest.left + margin, guest.bottom)
|
|
|
|
..lineTo(guest.right - margin, guest.bottom)
|
|
|
|
..quadraticBezierTo(
|
|
|
|
guest.right, guest.bottom, guest.right, guest.bottom - margin)
|
|
|
|
..lineTo(guest.right, host.top + margin)
|
|
|
|
..quadraticBezierTo(guest.right, host.top, guest.right + margin, host.top)
|
|
|
|
..lineTo(host.right, host.top)
|
|
|
|
..lineTo(host.right, host.bottom)
|
|
|
|
..lineTo(host.left, host.bottom)
|
|
|
|
..close();
|
|
|
|
}
|
|
|
|
}
|