mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-21 09:32:30 +01:00
kuhy_credit: keep logo size in stretching parents
Some checks are pending
file length / file-length (push) Waiting to run
kuhy_credit drift / drift (push) Waiting to run
kuhy_credit tests / python (push) Waiting to run
kuhy_credit tests / web (push) Waiting to run
kuhy_credit tests / flutter (push) Waiting to run
kuhy_credit tests / godot (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run
Some checks are pending
file length / file-length (push) Waiting to run
kuhy_credit drift / drift (push) Waiting to run
kuhy_credit tests / python (push) Waiting to run
kuhy_credit tests / web (push) Waiting to run
kuhy_credit tests / flutter (push) Waiting to run
kuhy_credit tests / godot (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run
A ListView child got the full row width; the painter scaled the dark field across the row and the glyph left the clip, so the logo was invisible in punchme's settings. Loosen constraints at the root and scale by the short side. Release 0.3.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3fffb413b2
commit
2352c17723
@ -44,7 +44,7 @@ Nothing loads over the network and nothing opens without a click.
|
||||
|
||||
```jsonc
|
||||
// package.json
|
||||
"@kuhyx/kuhy-credit": "github:kuhyx/utils#kuhy-credit-v0.3.0&path:kuhy_credit/web"
|
||||
"@kuhyx/kuhy-credit": "github:kuhyx/utils#kuhy-credit-v0.3.1&path:kuhy_credit/web"
|
||||
```
|
||||
|
||||
```html
|
||||
@ -70,7 +70,7 @@ dependencies:
|
||||
kuhy_credit:
|
||||
git:
|
||||
url: https://github.com/kuhyx/utils
|
||||
ref: kuhy-credit-v0.3.0
|
||||
ref: kuhy-credit-v0.3.1
|
||||
path: kuhy_credit/flutter
|
||||
```
|
||||
|
||||
@ -87,7 +87,7 @@ app on Android). Back closes an open panel. Demo: `flutter/example`.
|
||||
|
||||
```bash
|
||||
cache="$(mktemp -d)"
|
||||
git clone --depth 1 --branch kuhy-credit-v0.3.0 https://github.com/kuhyx/utils "$cache"
|
||||
git clone --depth 1 --branch kuhy-credit-v0.3.1 https://github.com/kuhyx/utils "$cache"
|
||||
cp -r "$cache/kuhy_credit/godot/addons/kuhy_credit" addons/
|
||||
```
|
||||
|
||||
@ -103,7 +103,7 @@ The script opens the site with `OS.shell_open`. Demo:
|
||||
## Python / Tkinter
|
||||
|
||||
```bash
|
||||
pip install "kuhy-credit @ git+https://github.com/kuhyx/utils@kuhy-credit-v0.3.0#subdirectory=kuhy_credit"
|
||||
pip install "kuhy-credit @ git+https://github.com/kuhyx/utils@kuhy-credit-v0.3.1#subdirectory=kuhy_credit"
|
||||
```
|
||||
|
||||
```python
|
||||
@ -124,7 +124,7 @@ vector TikZ, no image file) and makes it a link to the site. No words appear.
|
||||
```bash
|
||||
# vendor the generated package from the tag, like the Godot addon
|
||||
cache="$(mktemp -d)"
|
||||
git clone --depth 1 --branch kuhy-credit-v0.3.0 https://github.com/kuhyx/utils "$cache"
|
||||
git clone --depth 1 --branch kuhy-credit-v0.3.1 https://github.com/kuhyx/utils "$cache"
|
||||
cp "$cache/kuhy_credit/latex/kuhy-credit.sty" kuhy-credit/
|
||||
TEXINPUTS="$PWD/kuhy-credit//:" pdflatex doc.tex
|
||||
```
|
||||
|
||||
@ -70,7 +70,7 @@ packages:
|
||||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "0.3.0"
|
||||
version: "0.3.1"
|
||||
leak_tracker:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@ -129,38 +129,47 @@ class _KuhyCreditState extends State<KuhyCredit> {
|
||||
),
|
||||
),
|
||||
);
|
||||
return PopScope(
|
||||
canPop: !_portal.isShowing,
|
||||
onPopInvokedWithResult: (didPop, _) {
|
||||
if (!didPop) _close();
|
||||
},
|
||||
child: TapRegion(
|
||||
groupId: this,
|
||||
onTapOutside: (_) => _close(),
|
||||
child: CompositedTransformTarget(
|
||||
link: _link,
|
||||
child: OverlayPortal(
|
||||
controller: _portal,
|
||||
overlayChildBuilder: (context) => CompositedTransformFollower(
|
||||
link: _link,
|
||||
targetAnchor: Alignment(end ? 1 : -1, above ? -1 : 1),
|
||||
followerAnchor: Alignment(end ? 1 : -1, above ? 1 : -1),
|
||||
offset: Offset(0, above ? -kSpaceSm : kSpaceSm),
|
||||
child: Align(
|
||||
alignment: Alignment(end ? 1 : -1, above ? 1 : -1),
|
||||
child: TapRegion(
|
||||
groupId: this,
|
||||
child: _Panel(
|
||||
dark: dark,
|
||||
size: widget.size,
|
||||
focusNode: _panelFocus,
|
||||
onKey: _onPanelKey,
|
||||
onTap: _activate,
|
||||
// A stretching parent (ListView, Column.stretch) would force the logo
|
||||
// to the full row width: the painter then scaled the dark field across
|
||||
// the screen and the glyph fell outside the clip, an invisible logo.
|
||||
// Loosen the constraints here so the logo, the tap target and the panel
|
||||
// anchor all keep [KuhyCredit.size].
|
||||
return Center(
|
||||
widthFactor: 1,
|
||||
heightFactor: 1,
|
||||
child: PopScope(
|
||||
canPop: !_portal.isShowing,
|
||||
onPopInvokedWithResult: (didPop, _) {
|
||||
if (!didPop) _close();
|
||||
},
|
||||
child: TapRegion(
|
||||
groupId: this,
|
||||
onTapOutside: (_) => _close(),
|
||||
child: CompositedTransformTarget(
|
||||
link: _link,
|
||||
child: OverlayPortal(
|
||||
controller: _portal,
|
||||
overlayChildBuilder: (context) => CompositedTransformFollower(
|
||||
link: _link,
|
||||
targetAnchor: Alignment(end ? 1 : -1, above ? -1 : 1),
|
||||
followerAnchor: Alignment(end ? 1 : -1, above ? 1 : -1),
|
||||
offset: Offset(0, above ? -kSpaceSm : kSpaceSm),
|
||||
child: Align(
|
||||
alignment: Alignment(end ? 1 : -1, above ? 1 : -1),
|
||||
child: TapRegion(
|
||||
groupId: this,
|
||||
child: _Panel(
|
||||
dark: dark,
|
||||
size: widget.size,
|
||||
focusNode: _panelFocus,
|
||||
onKey: _onPanelKey,
|
||||
onTap: _activate,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: logo,
|
||||
),
|
||||
child: logo,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@ -16,8 +16,11 @@ class _LogoPainter extends CustomPainter {
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
// Scale by the short side and clip, so a non-square box can never
|
||||
// push the glyph out of view.
|
||||
canvas
|
||||
..scale(size.width / kLogoSize)
|
||||
..clipRect(Offset.zero & size)
|
||||
..scale(size.shortestSide / kLogoSize)
|
||||
..drawRect(
|
||||
const Rect.fromLTWH(0, 0, kLogoSize, kLogoSize),
|
||||
Paint()..color = const Color(kLogoField),
|
||||
|
||||
@ -3,7 +3,7 @@ description: >-
|
||||
The shared "Created by kuhy" credit: an M1 logo button that opens a small
|
||||
panel, whose tap opens kuhy.duckdns.org. Android and Flutter web.
|
||||
publish_to: 'none'
|
||||
version: 0.3.0
|
||||
version: 0.3.1
|
||||
|
||||
environment:
|
||||
sdk: ^3.12.2
|
||||
|
||||
27
kuhy_credit/flutter/test/kuhy_credit_layout_test.dart
Normal file
27
kuhy_credit/flutter/test/kuhy_credit_layout_test.dart
Normal file
@ -0,0 +1,27 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:kuhy_credit/kuhy_credit.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('a stretching parent (ListView) keeps the logo at its size', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
WidgetsApp(
|
||||
color: const Color(kDarkBg),
|
||||
pageRouteBuilder: <T>(settings, builder) => PageRouteBuilder<T>(
|
||||
settings: settings,
|
||||
pageBuilder: (context, _, _) => builder(context),
|
||||
),
|
||||
home: ListView(children: const [KuhyCredit(size: 40)]),
|
||||
),
|
||||
);
|
||||
final logo = find.byKey(KuhyCredit.logoKey);
|
||||
expect(tester.getSize(logo), const Size(40, 40));
|
||||
// The tap target shrank with the logo: the row's far end opens nothing.
|
||||
final row = tester.getRect(find.byType(KuhyCredit));
|
||||
await tester.tapAt(row.centerRight - const Offset(4, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(KuhyCredit.panelKey), findsNothing);
|
||||
});
|
||||
}
|
||||
@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "kuhy-credit"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
description = "The shared 'Created by kuhy' logo credit: Tkinter widget and terminal line"
|
||||
requires-python = ">=3.14"
|
||||
dependencies = [] # pure stdlib: tkinter and webbrowser ship with Python
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kuhyx/kuhy-credit",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.1",
|
||||
"private": false,
|
||||
"type": "module",
|
||||
"description": "<kuhy-credit>: the shared 'Created by kuhy' logo credit as a dependency-free custom element.",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user