-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/bump-flutter-ci-to-3.2.04
- Loading branch information
Showing
9 changed files
with
263 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
catalyst_voices/lib/widgets/buttons/voices_keyboard_key_button.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import 'package:catalyst_voices/widgets/tooltips/voices_plain_tooltip.dart'; | ||
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart'; | ||
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
/// Widget that is meant to be used as singular keyboard key indication. | ||
/// | ||
/// Common use case is to show list of such keys that together means | ||
/// shortcut of some sorts. | ||
/// | ||
/// See: | ||
/// * [VoicesPlainTooltip] as good starting points for used of this button. | ||
class VoicesKeyboardKeyButton extends StatelessWidget { | ||
/// Usually [Icon], [CatalystSvgIcon] or [Text]. | ||
final Widget child; | ||
|
||
const VoicesKeyboardKeyButton({ | ||
super.key, | ||
required this.child, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final theme = Theme.of(context); | ||
|
||
final iconTheme = IconThemeData( | ||
size: 14, | ||
color: theme.colors.iconsForeground, | ||
); | ||
|
||
final textStyle = TextStyle( | ||
fontSize: 14, | ||
fontWeight: FontWeight.w700, | ||
height: 1, | ||
color: theme.colors.textPrimary, | ||
); | ||
|
||
return IconTheme( | ||
data: iconTheme, | ||
child: DefaultTextStyle( | ||
style: textStyle, | ||
textAlign: TextAlign.center, | ||
child: ConstrainedBox( | ||
constraints: const BoxConstraints(minWidth: 23.3, minHeight: 23.3), | ||
child: DecoratedBox( | ||
decoration: BoxDecoration( | ||
borderRadius: BorderRadius.circular(4.6), | ||
color: const Color(0xFFD9D9D9), | ||
), | ||
child: Container( | ||
margin: const EdgeInsets.only( | ||
left: 2.3, | ||
top: 1.17, | ||
right: 2.3, | ||
bottom: 3.5, | ||
), | ||
decoration: BoxDecoration( | ||
color: theme.colorScheme.onPrimary, | ||
borderRadius: BorderRadius.circular(2.3), | ||
), | ||
alignment: Alignment.center, | ||
child: child, | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
catalyst_voices/lib/widgets/buttons/voices_logical_keyboard_key_button.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'package:catalyst_voices/widgets/buttons/voices_keyboard_key_button.dart'; | ||
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
|
||
final Map<int, SvgGenImage> _keyIconMapping = { | ||
LogicalKeyboardKey.control.keyId: VoicesAssets.icons.chevronUp, | ||
}; | ||
|
||
/// Wrapper for [VoicesKeyboardKeyButton] and [LogicalKeyboardKey]. | ||
/// | ||
/// This widget takes care or proper mapping of [data] to corresponding | ||
/// widget that should indicate given key. | ||
/// | ||
/// See [_keyIconMapping] for list of icons with iconographic representation. If | ||
/// no icon is found for such [LogicalKeyboardKey] first letter | ||
/// of [LogicalKeyboardKey.keyLabel] will be used as fallback. | ||
class VoicesLogicalKeyboardKeyButton extends StatelessWidget { | ||
final LogicalKeyboardKey data; | ||
|
||
const VoicesLogicalKeyboardKeyButton( | ||
this.data, { | ||
super.key, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return VoicesKeyboardKeyButton( | ||
child: _buildKeyIndicator(context), | ||
); | ||
} | ||
|
||
Widget _buildKeyIndicator(BuildContext context) { | ||
final keyIcon = _keyIconMapping[data.keyId]; | ||
if (keyIcon != null) { | ||
return keyIcon.buildIcon(); | ||
} | ||
|
||
final keyLabel = data.keyLabel; | ||
final letter = keyLabel.isNotEmpty ? keyLabel.substring(0, 1) : null; | ||
if (letter != null) { | ||
return Text(letter.toUpperCase()); | ||
} | ||
|
||
return const SizedBox.shrink(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
catalyst_voices/lib/widgets/common/shortcut_activator_view.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:catalyst_voices/widgets/buttons/voices_logical_keyboard_key_button.dart'; | ||
import 'package:catalyst_voices_shared/catalyst_voices_shared.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
/// Grouping all [LogicalKeyboardKey] that correspond with given [activator] | ||
/// and shows them in a [Row] as [VoicesLogicalKeyboardKeyButton]. | ||
/// | ||
/// This widget also uses [LogicalKeyboardKey.collapseSynonyms] to remove | ||
/// any synonyms key activator such as left Control and right Control. | ||
class ShortcutActivatorView extends StatelessWidget { | ||
final ShortcutActivator activator; | ||
|
||
const ShortcutActivatorView({ | ||
super.key, | ||
required this.activator, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final triggers = {...?activator.triggers}; | ||
|
||
return Row( | ||
mainAxisSize: MainAxisSize.min, | ||
children: LogicalKeyboardKey.collapseSynonyms(triggers) | ||
.map<Widget>(VoicesLogicalKeyboardKeyButton.new) | ||
.separatedBy(const SizedBox(width: 4)) | ||
.toList(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.