fix: remove element example in storybook
This commit is contained in:
parent
774d05a735
commit
c63282dfba
|
@ -62,59 +62,5 @@ List<Story> getStories(GolekThemeData theme) {
|
|||
inputLabel: '',
|
||||
),
|
||||
),
|
||||
Story.simple(
|
||||
name: 'Simple Expanded Elevated Button',
|
||||
section: 'Buttons',
|
||||
child: ExpandedElevatedButton(
|
||||
label: 'Press me',
|
||||
onTap: () {},
|
||||
),
|
||||
),
|
||||
Story(
|
||||
name: 'Expanded Elevated Button',
|
||||
section: 'Buttons',
|
||||
builder: (_, k) => ExpandedElevatedButton(
|
||||
label: k.text(
|
||||
label: 'label',
|
||||
initial: 'Press me',
|
||||
),
|
||||
onTap: k.boolean(
|
||||
label: 'onTap',
|
||||
initial: true,
|
||||
)
|
||||
? () {}
|
||||
: null,
|
||||
icon: Icon(
|
||||
k.options<IconData>(
|
||||
label: 'icon',
|
||||
initial: Icons.home,
|
||||
options: const [
|
||||
Option(
|
||||
'Login',
|
||||
Icons.login,
|
||||
),
|
||||
Option(
|
||||
'Refresh',
|
||||
Icons.refresh,
|
||||
),
|
||||
Option(
|
||||
'Logout',
|
||||
Icons.logout,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Story(
|
||||
name: 'InProgress Expanded Elevated Button',
|
||||
section: 'Buttons',
|
||||
builder: (_, k) => ExpandedElevatedButton.inProgress(
|
||||
label: k.text(
|
||||
label: 'label',
|
||||
initial: 'Processing',
|
||||
),
|
||||
),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
export 'src/expanded_elevated_button.dart';
|
||||
export 'src/l10n/component_library_localizations.dart';
|
||||
export 'src/theme/font_size.dart';
|
||||
export 'src/theme/spacing.dart';
|
||||
|
@ -7,4 +6,3 @@ export 'src/theme/golek_theme_data.dart';
|
|||
export 'src/input_field.dart';
|
||||
export 'src/input_file.dart';
|
||||
export 'src/error_message_builder.dart';
|
||||
export 'src/favorite_icon_button.dart';
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class ExpandedElevatedButton extends StatelessWidget {
|
||||
static const double _elevatedButtonHeight = 48;
|
||||
|
||||
const ExpandedElevatedButton({
|
||||
required this.label,
|
||||
this.onTap,
|
||||
this.icon,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
ExpandedElevatedButton.inProgress({
|
||||
required String label,
|
||||
Key? key,
|
||||
}) : this(
|
||||
label: label,
|
||||
icon: Transform.scale(
|
||||
scale: 0.5,
|
||||
child: const CircularProgressIndicator(),
|
||||
),
|
||||
key: key,
|
||||
);
|
||||
|
||||
final VoidCallback? onTap;
|
||||
final String label;
|
||||
final Widget? icon;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final icon = this.icon;
|
||||
return SizedBox(
|
||||
height: _elevatedButtonHeight,
|
||||
width: double.infinity,
|
||||
child: icon != null
|
||||
? ElevatedButton.icon(
|
||||
onPressed: onTap,
|
||||
label: Text(
|
||||
label,
|
||||
),
|
||||
icon: icon,
|
||||
)
|
||||
: ElevatedButton(
|
||||
onPressed: onTap,
|
||||
child: Text(
|
||||
label,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
import 'package:component_library/component_library.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class FavoriteIconButton extends StatelessWidget {
|
||||
const FavoriteIconButton({
|
||||
required this.isFavorite,
|
||||
this.onTap,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
final bool isFavorite;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = ComponentLibraryLocalizations.of(context);
|
||||
return IconButton(
|
||||
onPressed: onTap,
|
||||
tooltip: l10n.favoriteIconButtonTooltip,
|
||||
icon: Icon(
|
||||
isFavorite ? Icons.favorite : Icons.favorite_border_outlined,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
import 'package:component_library/component_library.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('FavoriteIconButton tests: ', () {
|
||||
testWidgets('onTap() callback is executed when tapping on button',
|
||||
(tester) async {
|
||||
bool value = false;
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
locale: const Locale('en'),
|
||||
localizationsDelegates: const [ComponentLibraryLocalizations.delegate],
|
||||
home: Scaffold(
|
||||
body: FavoriteIconButton(
|
||||
isFavorite: false,
|
||||
onTap: () {
|
||||
value = !value;
|
||||
}),
|
||||
),
|
||||
));
|
||||
|
||||
await tester.tap(find.byType(FavoriteIconButton));
|
||||
|
||||
expect(value, true);
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue