mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
* add commit/branch overlay for ci builds * add ability to show/hide overlay * add alert when disabling the overlay
61 lines
1.9 KiB
Dart
61 lines
1.9 KiB
Dart
import "package:cake_wallet/store/settings_store.dart";
|
|
import "package:flutter/material.dart";
|
|
import "package:flutter_mobx/flutter_mobx.dart";
|
|
|
|
class CiBuildOverlay extends StatelessWidget {
|
|
const CiBuildOverlay({required this.child, this.settingsStore, super.key});
|
|
|
|
static const _commit = String.fromEnvironment("CI_COMMIT");
|
|
static const _branch = String.fromEnvironment("CI_BRANCH");
|
|
static const isCiBuild = _commit != "" || _branch != "";
|
|
|
|
final Widget child;
|
|
final SettingsStore? settingsStore;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (!isCiBuild) {
|
|
return child;
|
|
}
|
|
|
|
final shortCommit = _commit.length > 7 ? _commit.substring(0, 7) : _commit;
|
|
final label = [shortCommit, _branch].where((part) => part.isNotEmpty).join(" · ");
|
|
|
|
return Stack(
|
|
fit: StackFit.passthrough,
|
|
textDirection: TextDirection.ltr,
|
|
children: [
|
|
child,
|
|
Positioned(
|
|
top: 0,
|
|
left: 0,
|
|
right: 0,
|
|
child: Observer(
|
|
builder: (_) => settingsStore?.showCiBuildOverlay ?? true
|
|
? IgnorePointer(
|
|
child: ExcludeSemantics(
|
|
child: SafeArea(
|
|
bottom: false,
|
|
child: ColoredBox(
|
|
color: Colors.black54,
|
|
child: Text(
|
|
label,
|
|
textAlign: TextAlign.center,
|
|
textDirection: TextDirection.ltr,
|
|
textScaler: TextScaler.noScaling,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(color: Colors.white, fontSize: 10),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
)
|
|
: const SizedBox.shrink(),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|