Skip to content

Commit c7f537d

Browse files
committed
feat(bull_ui): seed design-system package with duplicated core widgets
1 parent 2383889 commit c7f537d

64 files changed

Lines changed: 4937 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/core/themes/app_theme.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,39 @@
11
import 'package:bb_mobile/core/themes/colors.dart';
22
import 'package:bb_mobile/core/themes/fonts.dart';
3+
import 'package:bull_ui/bull_ui.dart';
34
import 'package:flutter/material.dart';
45
import 'package:flutter/services.dart';
56

67
enum AppThemeType { light, dark }
78

9+
/// Builds the `bull_ui` [BullTheme] colour extension from an [AppColors]
10+
/// palette. `bull_ui` is brightness-agnostic — the app hands it the right
11+
/// palette per brightness, so `AppColors` stays the single source of truth.
12+
BullTheme _bullThemeFrom(AppColors colors) {
13+
return BullTheme(
14+
red: colors.primary,
15+
onRed: colors.onPrimary,
16+
surface: colors.surface,
17+
card: colors.cardBackground,
18+
text: colors.text,
19+
muted: colors.textMuted,
20+
info: colors.info,
21+
success: colors.success,
22+
warning: colors.warning,
23+
btc: colors.onTertiary,
24+
outlineVariant: colors.outlineVariant,
25+
shimmerBase: colors.shimmerBase,
26+
shimmerHighlight: colors.shimmerHighlight,
27+
secondary: colors.secondary,
28+
onSecondary: colors.onSecondary,
29+
secondaryFixedDim: colors.secondaryFixedDim,
30+
border: colors.border,
31+
onSurface: colors.onSurface,
32+
onSurfaceVariant: colors.onSurfaceVariant,
33+
scrim: colors.scrim,
34+
);
35+
}
36+
837
class AppTheme {
938
static ThemeData themeData(AppThemeType themeType) {
1039
final colors = themeType == AppThemeType.dark
@@ -18,6 +47,7 @@ class AppTheme {
1847
return ThemeData(
1948
useMaterial3: true,
2049
brightness: brightness,
50+
extensions: [_bullThemeFrom(colors)],
2151
colorScheme: ColorScheme.fromSeed(
2252
seedColor: colors.primary,
2353
brightness: brightness,

packages/bull_ui/CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Changelog
2+
3+
## Unreleased
4+
5+
- Expand `BullTheme` with `secondary`, `onSecondary`, `secondaryFixedDim`,
6+
`border`, `onSurface`, `onSurfaceVariant` and `scrim` (plus `copyWith`/`lerp`
7+
and the app-side `_bullThemeFrom` builder), sourced from `AppColors`.
8+
- Duplicate the dependency-clean set of `lib/core/widgets/**` as `Bull*`
9+
copies: `BullInputText`, `BullPasteInput`, `BullDropdown`,
10+
`BullSelectableList`, `BullDialPad`, `BullAmountInputFormatter`,
11+
`BullLowerCaseTextFormatter`, `BullCountdown`, `BullFadingLinearProgress`,
12+
`BullScrollableColumn`, `BullStackedPage`, `BullPullableBody`,
13+
`BullOptionsTag`, `BullInfoCard`, `BullPriceCard`, `BullBackupOptionCard`,
14+
`BullBorderedTile`, `BullTransactionDirectionBadge`, `BullSettingsEntryItem`,
15+
`BullTabMenuVerticalButton`, `BullViewerActionButton`. See the README
16+
"Components" / "Not yet migrated" tables.
17+
- Duplicate the remaining dependency-clean widgets: `BullDetailsTable` +
18+
`BullDetailsTableItem` (`DetailsTable` / `DetailsTableItem`),
19+
`BullPickerSheet` (`BBPickerSheet`) and `BullInstructionsSheet`
20+
(`InstructionsBottomSheet`). No new `BullTheme` fields were required — they
21+
reuse the existing `surface`, `border`, `onSurface`, `red` and `text` colours.
22+
- Widget tests for `BullDropdown`, `BullCountdown` and `BullDialPad`.
23+
24+
## 0.0.1
25+
26+
- Seed the `bull_ui` design-system package: `BullTheme` (`ThemeExtension`),
27+
`BullRadius`/`BullSpacing`/`BullTextStyles`/`BullIcon` tokens, and the first
28+
set of `Bull*` components for the Coins view (issue #760).

packages/bull_ui/README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# bull_ui
2+
3+
The Bull Bitcoin design-system component library — the go-forward source of truth for
4+
shared UI primitives. It is the first melos workspace member (`packages/bull_ui`).
5+
6+
Every public widget is prefixed `Bull*` (e.g. `BullText`, `BullButton`, `BullScaffold`).
7+
This prefix is provenance: **`BB*` = legacy widgets in `lib/core/widgets`, `Bull*` = here**.
8+
The two coexist during the incremental migration; `BB*` originals are retired
9+
feature-by-feature in later scoped PRs as usages migrate. Nothing is moved or renamed —
10+
`bull_ui` components are duplicated copies, so existing app code is untouched.
11+
12+
## Theme injection
13+
14+
`bull_ui` is **brightness-agnostic** and never hardcodes a colour. The app injects the
15+
palette: it builds a `BullTheme` (a `ThemeExtension`) from `AppColors.light` and another
16+
from `AppColors.dark`, and registers each on the matching `ThemeData` via `extensions:`.
17+
Components read colours through `context.bull` (e.g. `context.bull.red`); derived fills use
18+
`tokenColor.withValues(alpha: …)` so they adapt to both light and dark automatically.
19+
20+
Brightness-invariant tokens (radii, spacing, type over Golos Text) are static consts:
21+
`BullRadius`, `BullSpacing`, `BullTextStyles`. Icons are wrapped via `BullIcon(BullIcons.…)`.
22+
23+
Fonts (Golos Text, Bebas Neue) are declared at the app root and resolve by family name
24+
across the workspace — `bull_ui` references them by name and does not re-ship the `.ttf`s.
25+
26+
## Import surface
27+
28+
Consumers import a single barrel:
29+
30+
```dart
31+
import 'package:bull_ui/bull_ui.dart';
32+
```
33+
34+
It re-exports a curated `show` list of `package:flutter/widgets.dart` layout/foundation
35+
symbols plus every `Bull*` component and the theme. Internals live under `lib/src/`.
36+
37+
## Components
38+
39+
Duplicated from `lib/core/widgets/**` as dependency-clean `Bull*` copies (the
40+
`BB*`/core originals are left untouched). Grouped by barrel category:
41+
42+
**Buttons**`BullButton`, `BullToolButton`, `BullTabMenuVerticalButton`
43+
(`TabMenuVerticalButton`), `BullViewerActionButton` (`ViewerActionButton`).
44+
45+
**Inputs**`BullCheckbox`, `BullFilterChip`, `BullInputText` (`BBInputText`),
46+
`BullPasteInput` (`PasteInput`), `BullDropdown` (`BBDropdown`),
47+
`BullSelectableList` + `BullSelectableListItem` (`SelectableList`),
48+
`BullDialPad` (`DialPad`), `BullAmountInputFormatter` (`AmountInputFormatter`),
49+
`BullLowerCaseTextFormatter` (`LowerCaseTextFormatter`).
50+
51+
**Controls**`BullSegmented`, `BullSwipeAction`, `BullSwitch` (`BBSwitch`).
52+
53+
**Feedback**`BullRefreshIndicator` (`BBRefreshIndicator`), `BullShimmerBox`/
54+
`BullShimmerLine`, `BullSnackBar`, `BullCountdown` (`Countdown`),
55+
`BullFadingLinearProgress` (`FadingLinearProgress`).
56+
57+
**Layout**`BullScrollableColumn` (`ScrollableColumn`), `BullStackedPage`
58+
(`StackedPage`), `BullPullableBody` (`BBPullableBody`).
59+
60+
**Data display**`BullAddressText`, `BullBadge`, `BullInfoBar`,
61+
`BullLabelChip`, `BullStatTile`, `BullText` (`BBText`), `BullOptionsTag`
62+
(`OptionsTag`), `BullInfoCard` (`InfoCard`), `BullPriceCard` (`PriceCard`),
63+
`BullBackupOptionCard` (`BackupOptionCard`), `BullBorderedTile`
64+
(`BorderedTappableTile`), `BullTransactionDirectionBadge`
65+
(`TransactionDirectionBadge`), `BullSettingsEntryItem` (`SettingsEntryItem`),
66+
`BullDetailsTable` + `BullDetailsTableItem` (`DetailsTable` / `DetailsTableItem`).
67+
68+
**Overlays**`BullBottomSheet`, `BullDialog`, `BullPickerSheet`
69+
(`BBPickerSheet`), `BullInstructionsSheet` (`InstructionsBottomSheet`).
70+
71+
**Chrome**`BullScaffold`, `BullTopBar`, `BullSelectionActionBar`.
72+
73+
## Not yet migrated (needs dep abstraction)
74+
75+
These `core/widgets` widgets still reach into `package:bb_mobile/*` (or otherwise
76+
can't preserve their public API on top of the clean kit) and are **deferred**
77+
until the dependency is abstracted out of the widget:
78+
79+
| Widget | Blocker |
80+
| --- | --- |
81+
| `MultiTapTrigger` | `package:bb_mobile/core/widgets/snackbar_utils.dart` — its public `tapsReachedMessageTextColor` / `tapsReachedMessageBackgroundColor` API can't be honoured by `BullSnackBar.show` (String-only), so migrating would lose API. |
82+
| `CopyInput`, `BBKeyboardActions` | depend on `package:bb_mobile/*` localization / app utils. |
83+
| `BBButton` (`buttons/button.dart`) | already superseded by `BullButton`; not a 1:1 copy. |
84+
| Cards: `ActionCard`, `AutoswapWarningCard`, `BackupCard`, `BalanceCard`, `ProviderCart`, `WalletCard` | `package:bb_mobile/*` (router, l10n, feature models, `Assets`). |
85+
| `BBKeyboardActions` | needs `package:keyboard_actions/keyboard_actions.dart`, not declared in `bull_ui/pubspec.yaml` (no new deps rule). |
86+
| Bottom sheets: `AdvancedOptions`, `ComingSoon`, `Warning`, `NotLoggedIn`, `DeleteAccount*`, `Logout*`, `TranslationWarning` | `context.loc` localization and/or `package:bb_mobile/*` router & assets. |
87+
| Cards: `AutoswapWarningCard` | `context.loc` (`autoswapWarningCard*` strings) + `context.font` from `package:bb_mobile/core/utils/build_context_x.dart`. |
88+
| Loading: `ProgressScreen`, `StatusScreen` | `ProgressScreen` imports `package:bb_mobile/generated/flutter_gen/assets.gen.dart`; `StatusScreen` uses `context.loc` + `BBButton`. |
89+
| Viewers: `AddressViewer`, `TransactionViewer`, `InvoiceViewer`, `LogViewer`, `QrScanner`, `NfcScanner`, `ShareLogs`, `Bip85Derivation`, `MnemonicWidget`, `CoinSelectionBottomSheet`, `AppLanguagePicker`, `BackupSuccessScreen`, `PriceInput`, `TransactionsByDayList`, `BalanceRow`, `RecoverbullVaultProviderSelector` | `package:bb_mobile/*` (entities, l10n, assets, feature blocs). |
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
include: package:lints/recommended.yaml
2+
3+
linter:
4+
rules:
5+
# A design-system package is the foundation other features build on; hold it
6+
# to a stricter bar than the recommended set.
7+
- prefer_const_constructors
8+
- prefer_const_constructors_in_immutables
9+
- prefer_const_declarations
10+
- prefer_const_literals_to_create_immutables
11+
- require_trailing_commas
12+
- prefer_final_locals
13+
- prefer_single_quotes
14+
- sort_child_properties_last
15+
- use_super_parameters
16+
- unnecessary_parenthesis

packages/bull_ui/lib/bull_ui.dart

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/// The Bull Bitcoin design-system component library.
2+
///
3+
/// Import this single barrel; it re-exports a curated `show` list of Flutter
4+
/// layout/foundation primitives plus every `Bull*` component and the theme.
5+
/// Internals live under `lib/src/`.
6+
library;
7+
8+
// Curated re-export of Flutter foundation/layout primitives (Decision D5).
9+
// A blanket `export 'package:flutter/widgets.dart'` is deliberately avoided —
10+
// the list grows on demand as components need more symbols.
11+
export 'package:flutter/widgets.dart'
12+
show
13+
Align,
14+
Alignment,
15+
AnimatedContainer,
16+
AnimatedPositioned,
17+
AspectRatio,
18+
Axis,
19+
BorderRadius,
20+
BoxConstraints,
21+
BoxDecoration,
22+
BuildContext,
23+
Center,
24+
Color,
25+
Column,
26+
ConstrainedBox,
27+
CrossAxisAlignment,
28+
EdgeInsets,
29+
EdgeInsetsGeometry,
30+
Expanded,
31+
Flexible,
32+
FractionallySizedBox,
33+
GestureDetector,
34+
HitTestBehavior,
35+
IconData,
36+
Key,
37+
ListView,
38+
MainAxisAlignment,
39+
MainAxisSize,
40+
Opacity,
41+
Padding,
42+
Positioned,
43+
Radius,
44+
Row,
45+
SafeArea,
46+
SingleChildScrollView,
47+
SizedBox,
48+
Spacer,
49+
Stack,
50+
State,
51+
StatefulWidget,
52+
StatelessWidget,
53+
Text,
54+
TextAlign,
55+
TextBaseline,
56+
TextDirection,
57+
TextEditingController,
58+
TextOverflow,
59+
TextStyle,
60+
ValueChanged,
61+
VerticalDirection,
62+
VoidCallback,
63+
Widget,
64+
Wrap;
65+
66+
// Material/services symbols required by component public APIs.
67+
export 'package:flutter/material.dart'
68+
show DropdownMenuItem, FormFieldValidator, RefreshCallback;
69+
export 'package:flutter/services.dart' show TextInputFormatter;
70+
export 'package:flutter/widgets.dart' show FocusNode;
71+
72+
export 'package:gap/gap.dart' show Gap;
73+
74+
// Theme.
75+
export 'src/theme/bull_icon.dart';
76+
export 'src/theme/bull_theme.dart';
77+
export 'src/theme/bull_tokens.dart';
78+
79+
// Chrome.
80+
export 'src/chrome/bull_scaffold.dart';
81+
export 'src/chrome/bull_selection_action_bar.dart';
82+
export 'src/chrome/bull_top_bar.dart';
83+
84+
// Buttons.
85+
export 'src/buttons/bull_button.dart';
86+
export 'src/buttons/bull_tab_menu_vertical_button.dart';
87+
export 'src/buttons/bull_tool_button.dart';
88+
export 'src/buttons/bull_viewer_action_button.dart';
89+
90+
// Inputs.
91+
export 'src/inputs/bull_amount_input_formatter.dart';
92+
export 'src/inputs/bull_checkbox.dart';
93+
export 'src/inputs/bull_dial_pad.dart';
94+
export 'src/inputs/bull_dropdown.dart';
95+
export 'src/inputs/bull_filter_chip.dart';
96+
export 'src/inputs/bull_input_text.dart';
97+
export 'src/inputs/bull_lowercase_input_formatter.dart';
98+
export 'src/inputs/bull_paste_input.dart';
99+
export 'src/inputs/bull_selectable_list.dart';
100+
101+
// Controls.
102+
export 'src/controls/bull_segmented.dart';
103+
export 'src/controls/bull_swipe_action.dart';
104+
export 'src/controls/bull_switch.dart';
105+
106+
// Feedback.
107+
export 'src/feedback/bull_countdown.dart';
108+
export 'src/feedback/bull_fading_linear_progress.dart';
109+
export 'src/feedback/bull_refresh_indicator.dart';
110+
export 'src/feedback/bull_shimmer.dart';
111+
export 'src/feedback/bull_snack_bar.dart';
112+
113+
// Layout.
114+
export 'src/layout/bull_pullable_body.dart';
115+
export 'src/layout/bull_scrollable_column.dart';
116+
export 'src/layout/bull_stacked_page.dart';
117+
118+
// Data display.
119+
export 'src/data_display/bull_address_text.dart';
120+
export 'src/data_display/bull_backup_option_card.dart';
121+
export 'src/data_display/bull_badge.dart';
122+
export 'src/data_display/bull_bordered_tile.dart';
123+
export 'src/data_display/bull_details_table.dart';
124+
export 'src/data_display/bull_info_bar.dart';
125+
export 'src/data_display/bull_info_card.dart';
126+
export 'src/data_display/bull_label_chip.dart';
127+
export 'src/data_display/bull_options_tag.dart';
128+
export 'src/data_display/bull_price_card.dart';
129+
export 'src/data_display/bull_settings_entry_item.dart';
130+
export 'src/data_display/bull_stat_tile.dart';
131+
export 'src/data_display/bull_text.dart';
132+
export 'src/data_display/bull_transaction_direction_badge.dart';
133+
134+
// Overlays.
135+
export 'src/overlays/bull_bottom_sheet.dart';
136+
export 'src/overlays/bull_dialog.dart';
137+
export 'src/overlays/bull_instructions_sheet.dart';
138+
export 'src/overlays/bull_picker_sheet.dart';

0 commit comments

Comments
 (0)