Skip to content

Commit ba0a2ec

Browse files
authored
Merge pull request #13 from Nuxify/feature/provide-other-widgets
feat: provide other widgets
2 parents 1a09d53 + 7d6adcb commit ba0a2ec

11 files changed

Lines changed: 171 additions & 5 deletions

File tree

ios/Runner.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@
510510
CODE_SIGN_STYLE = Automatic;
511511
CURRENT_PROJECT_VERSION = 1;
512512
GENERATE_INFOPLIST_FILE = YES;
513-
MARKETING_VERSION = 1.1.0;
513+
MARKETING_VERSION = 1.2.0;
514514
PRODUCT_BUNDLE_IDENTIFIER = com.example.nuxifyWidgetbook.RunnerTests;
515515
PRODUCT_NAME = "$(TARGET_NAME)";
516516
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
@@ -528,7 +528,7 @@
528528
CODE_SIGN_STYLE = Automatic;
529529
CURRENT_PROJECT_VERSION = 1;
530530
GENERATE_INFOPLIST_FILE = YES;
531-
MARKETING_VERSION = 1.1.0;
531+
MARKETING_VERSION = 1.2.0;
532532
PRODUCT_BUNDLE_IDENTIFIER = com.example.nuxifyWidgetbook.RunnerTests;
533533
PRODUCT_NAME = "$(TARGET_NAME)";
534534
SWIFT_VERSION = 5.0;
@@ -544,7 +544,7 @@
544544
CODE_SIGN_STYLE = Automatic;
545545
CURRENT_PROJECT_VERSION = 1;
546546
GENERATE_INFOPLIST_FILE = YES;
547-
MARKETING_VERSION = 1.1.0;
547+
MARKETING_VERSION = 1.2.0;
548548
PRODUCT_BUNDLE_IDENTIFIER = com.example.nuxifyWidgetbook.RunnerTests;
549549
PRODUCT_NAME = "$(TARGET_NAME)";
550550
SWIFT_VERSION = 5.0;

lib/indicators/widget_loader.dart

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:shimmer/shimmer.dart';
3+
4+
/// These are the static widgets that we're gonna use as skeleton loaders.
5+
/// We use the Text Widget with dummy values to emulate the the exact dimensions of specific widgets
6+
/// The text values won't show up because they are overlapped by the shimmer effect. It's just for height and width purposes.
7+
8+
const Duration fadeInDuration = Duration(milliseconds: 500);
9+
10+
class CardExpandedLoader extends StatelessWidget {
11+
const CardExpandedLoader({
12+
required this.height,
13+
this.baseColor = const Color(0xFF607D8B),
14+
this.highlightColor = const Color(0xFFCFD8DC),
15+
super.key,
16+
});
17+
final double height;
18+
final Color baseColor;
19+
final Color highlightColor;
20+
21+
@override
22+
Widget build(BuildContext context) {
23+
return Shimmer.fromColors(
24+
baseColor: baseColor,
25+
highlightColor: highlightColor,
26+
child: Container(
27+
decoration: BoxDecoration(
28+
borderRadius: BorderRadius.circular(8),
29+
color: baseColor.withOpacity(0.1),
30+
),
31+
margin: const EdgeInsets.only(right: 8),
32+
height: height,
33+
),
34+
);
35+
}
36+
}
37+
38+
class CardLoader extends StatelessWidget {
39+
const CardLoader({
40+
required this.height,
41+
required this.width,
42+
this.baseColor = const Color(0xFF607D8B),
43+
this.highlightColor = const Color(0xFFCFD8DC),
44+
super.key,
45+
});
46+
final double height;
47+
final double width;
48+
final Color baseColor;
49+
final Color highlightColor;
50+
51+
@override
52+
Widget build(BuildContext context) {
53+
return Shimmer.fromColors(
54+
baseColor: baseColor,
55+
highlightColor: highlightColor,
56+
child: Container(
57+
decoration: BoxDecoration(
58+
borderRadius: BorderRadius.circular(8),
59+
color: baseColor.withOpacity(0.1),
60+
),
61+
margin: const EdgeInsets.only(right: 8),
62+
height: height,
63+
width: width,
64+
),
65+
);
66+
}
67+
}

lib/input/filled_textfield.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class FilledTextField extends StatelessWidget {
3434
/// [suffix] A widget to display after the text field.
3535
///
3636
/// [prefix] A widget to display before the text field.
37+
///
38+
/// [enabled] is an optional parameter that specifies whether the text field is enabled.
3739
const FilledTextField({
3840
this.controller,
3941
this.fillColor,
@@ -53,6 +55,7 @@ class FilledTextField extends StatelessWidget {
5355
this.floatingLabelBehavior = FloatingLabelBehavior.always,
5456
this.suffix,
5557
this.prefix,
58+
this.enabled = true,
5659
super.key,
5760
});
5861
final Color? fillColor;
@@ -71,6 +74,7 @@ class FilledTextField extends StatelessWidget {
7174
final Widget? prefix;
7275
final Widget? suffix;
7376
final FloatingLabelBehavior floatingLabelBehavior;
77+
final bool enabled;
7478

7579
@override
7680
Widget build(BuildContext context) {
@@ -80,6 +84,7 @@ class FilledTextField extends StatelessWidget {
8084
style: textStyle,
8185
obscureText: obscureText,
8286
decoration: InputDecoration(
87+
enabled: enabled,
8388
prefixIcon: prefix,
8489
suffixIcon: suffix,
8590
hintText: hintText,

lib/input/outlined_textfield.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class OutlinedTextField extends StatelessWidget {
3838
/// [prefix] A widget to display before the text field.
3939
///
4040
/// [suffix] A widget to display after the text field.
41+
///
42+
/// [enabled] is an optional parameter that specifies whether the text field is enabled.
4143
const OutlinedTextField({
4244
this.controller,
4345
this.borderRadius = 30,
@@ -59,6 +61,7 @@ class OutlinedTextField extends StatelessWidget {
5961
this.floatingLabelBehavior = FloatingLabelBehavior.always,
6062
this.prefix,
6163
this.suffix,
64+
this.enabled = true,
6265
super.key,
6366
});
6467

@@ -79,6 +82,7 @@ class OutlinedTextField extends StatelessWidget {
7982
final Widget? prefix;
8083
final Widget? suffix;
8184
final FloatingLabelBehavior floatingLabelBehavior;
85+
final bool enabled;
8286

8387
@override
8488
Widget build(BuildContext context) {
@@ -88,6 +92,7 @@ class OutlinedTextField extends StatelessWidget {
8892
style: textStyle,
8993
obscureText: obscureText,
9094
decoration: InputDecoration(
95+
enabled: enabled,
9196
prefixIcon: prefix,
9297
suffixIcon: suffix,
9398
hintText: hintText,

lib/views/app_statusbar.dart

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter/services.dart';
3+
4+
/// A custom status bar widget with configurable colors and brightness for status and navigation bars.
5+
///
6+
/// [backgroundColor] sets the background color of the AppBar.
7+
///
8+
/// [statusBarColor] changes the color of the status bar.
9+
///
10+
/// [brightness] describes the contrast of a theme or color palette.
11+
class AppStatusBar extends StatelessWidget implements PreferredSizeWidget {
12+
const AppStatusBar({
13+
required this.brightness,
14+
this.backgroundColor,
15+
this.statusBarColor,
16+
Key? key,
17+
}) : super(key: key);
18+
final Color? backgroundColor;
19+
final Color? statusBarColor;
20+
final Brightness brightness;
21+
22+
@override
23+
Size get preferredSize => const Size.fromHeight(0);
24+
25+
@override
26+
Widget build(BuildContext context) {
27+
return PreferredSize(
28+
preferredSize: const Size(double.infinity, 0),
29+
child: AppBar(
30+
toolbarHeight: 0,
31+
elevation: 0,
32+
backgroundColor: backgroundColor,
33+
systemOverlayStyle: SystemUiOverlayStyle(
34+
statusBarIconBrightness: brightness,
35+
statusBarBrightness: brightness,
36+
systemNavigationBarIconBrightness: brightness,
37+
statusBarColor: statusBarColor,
38+
),
39+
),
40+
);
41+
}
42+
}

pubspec.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,14 @@ packages:
424424
url: "https://pub.dev"
425425
source: hosted
426426
version: "1.0.4"
427+
shimmer:
428+
dependency: "direct main"
429+
description:
430+
name: shimmer
431+
sha256: "5f88c883a22e9f9f299e5ba0e4f7e6054857224976a5d9f839d4ebdc94a14ac9"
432+
url: "https://pub.dev"
433+
source: hosted
434+
version: "3.0.0"
427435
sky_engine:
428436
dependency: transitive
429437
description: flutter

pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: nuxify_widgetbook
22
description: "A new Flutter project."
33
publish_to: "none"
4-
version: 1.1.0
4+
version: 1.2.0
55

66
environment:
77
sdk: ">=3.3.0 <4.0.0"
@@ -10,6 +10,7 @@ dependencies:
1010
flutter:
1111
sdk: flutter
1212
mobile_scanner: ^5.1.0
13+
shimmer: ^3.0.0
1314

1415
dev_dependencies:
1516
build_runner: ^2.4.9
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:nuxify_widgetbook/indicators/widget_loader.dart';
3+
import 'package:widgetbook/widgetbook.dart';
4+
import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook;
5+
6+
@widgetbook.UseCase(name: 'Default', type: CardExpandedLoader)
7+
Widget defaultUseCase(BuildContext context) {
8+
final int itemCount =
9+
context.knobs.int.slider(label: 'Loader Count', initialValue: 3, max: 10);
10+
11+
return Center(
12+
child: Container(
13+
color:
14+
!context.knobs.boolean(label: 'Dark background.', initialValue: true)
15+
? const Color(0xFFF5F7F8)
16+
: const Color(0xFF1E201E),
17+
padding: const EdgeInsets.symmetric(horizontal: 50),
18+
child: Center(
19+
child: Column(
20+
mainAxisSize: MainAxisSize.min,
21+
children: [
22+
for (int j = 0; j < itemCount; j++)
23+
Padding(
24+
padding: const EdgeInsets.only(bottom: 10.0),
25+
child: CardExpandedLoader(
26+
height: context.knobs.double
27+
.input(label: 'Card Loader Height', initialValue: 50),
28+
),
29+
)
30+
],
31+
),
32+
),
33+
),
34+
);
35+
}

widgetbook/lib/input/filled_textfield.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Widget defaultUseCase(BuildContext context) {
2323
isDense: context.knobs.boolean(label: 'TextField isDense'),
2424
obscureText: context.knobs.boolean(label: 'TextField obscureText'),
2525
fillColor: context.knobs.color(label: 'Fill Color'),
26+
enabled: context.knobs.boolean(label: 'Enabled', initialValue: true),
2627
borderRadius: context.knobs.double.slider(
2728
label: 'Border Radius', initialValue: 30, max: 50, min: 1),
2829
contentPadding: EdgeInsets.symmetric(

widgetbook/lib/input/outlined_textfield.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Widget defaultUseCase(BuildContext context) {
2525
mainAxisSize: MainAxisSize.min,
2626
children: <Widget>[
2727
OutlinedTextField(
28+
enabled:
29+
context.knobs.boolean(label: 'Enabled', initialValue: true),
2830
borderColor: context.knobs.color(label: 'Border Color'),
2931
errorBorderColor:
3032
context.knobs.color(label: 'Error Border Color'),

0 commit comments

Comments
 (0)