Skip to content

Commit 19832a3

Browse files
authored
feat: add text fields, text area, dropdown comun, dropdown multiple choice, dialog and selection control (#197)
1 parent 808a7ff commit 19832a3

16 files changed

+762
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import 'package:auto_route/auto_route.dart';
2+
import 'package:catalog/widgets/app_checkbox.dart';
3+
import 'package:flutter/material.dart';
4+
import 'package:gallery/catalog/catalog_scaffold_screen.dart';
5+
6+
@RoutePage()
7+
class CatalogAppCheckboxScreen extends StatelessWidget {
8+
const CatalogAppCheckboxScreen({super.key});
9+
10+
@override
11+
Widget build(BuildContext context) => CatalogScaffold(
12+
title: 'APP CHECKBOX',
13+
child: AppCheckbox(
14+
shrinkWrap: true,
15+
initialValue: true,
16+
onPressed: (bool? value) {},
17+
items: const [
18+
(value: false, title: 'Option 1', subtitle: null),
19+
(value: false, title: 'Option 2', subtitle: null),
20+
(value: false, title: 'Option 3', subtitle: null),
21+
(value: false, title: 'Option 4', subtitle: null),
22+
(value: false, title: 'Option 5', subtitle: null),
23+
(value: false, title: 'Option 6', subtitle: null),
24+
],
25+
),
26+
);
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import 'package:auto_route/auto_route.dart';
2+
import 'package:catalog/widgets/app_dialog.dart';
3+
import 'package:flutter/material.dart';
4+
import 'package:gallery/catalog/catalog_scaffold_screen.dart';
5+
6+
@RoutePage()
7+
class CatalogDialogScreen extends StatelessWidget {
8+
const CatalogDialogScreen({super.key});
9+
10+
@override
11+
Widget build(BuildContext context) => const CatalogScaffold(
12+
title: 'DIALOG',
13+
child: AppDialog(
14+
title: 'Modal title',
15+
content: 'This is place holder text. The basic dialog for modals '
16+
'should contain only valuable and relevant information. Simplify '
17+
'dialogs by removing unnecessary elements or content that does '
18+
'not support user tasks. If you find that the number of required '
19+
'elements for your design are making ',
20+
cancelButtonText: 'Cancel',
21+
actionButtonText: 'Confirm',
22+
),
23+
);
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import 'package:auto_route/auto_route.dart';
2+
import 'package:catalog/widgets/app_dropdown.dart';
3+
import 'package:flutter/material.dart';
4+
import 'package:gallery/catalog/catalog_scaffold_screen.dart';
5+
6+
@RoutePage()
7+
class CatalogDropdownScreen extends StatelessWidget {
8+
const CatalogDropdownScreen({super.key});
9+
10+
@override
11+
Widget build(BuildContext context) => CatalogScaffold(
12+
title: 'DROPDOWN',
13+
child: Container(
14+
margin: const EdgeInsets.all(20),
15+
child: Column(
16+
children: [
17+
AppDropdownMenu<int>(
18+
initialValue: 1,
19+
dropdownMenuEntries: const [
20+
(value: 1, label: 'Option 1'),
21+
(value: 2, label: 'Option 2'),
22+
(value: 3, label: 'Option 3'),
23+
(value: 4, label: 'Option 4'),
24+
(value: 5, label: 'Option 5'),
25+
(value: 6, label: 'Option 6'),
26+
],
27+
onSelected: (int? value) {},
28+
),
29+
],
30+
),
31+
),
32+
);
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'package:auto_route/auto_route.dart';
2+
import 'package:catalog/widgets/app_radio_button.dart';
3+
import 'package:flutter/material.dart';
4+
import 'package:gallery/catalog/catalog_scaffold_screen.dart';
5+
6+
@RoutePage()
7+
class CatalogAppRadioButtonScreen extends StatelessWidget {
8+
const CatalogAppRadioButtonScreen({super.key});
9+
10+
@override
11+
Widget build(BuildContext context) => CatalogScaffold(
12+
title: 'APP RADIO BUTTON',
13+
child: AppRadioButton(
14+
initialValue: 1,
15+
onPressed: (int? value) {},
16+
items: const [
17+
(value: 1, label: 'Option 1'),
18+
(value: 2, label: 'Option 2'),
19+
(value: 3, label: 'Option 3'),
20+
(value: 4, label: 'Option 4'),
21+
(value: 5, label: 'Option 5'),
22+
(value: 6, label: 'Option 6'),
23+
],
24+
),
25+
);
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import 'package:auto_route/auto_route.dart';
2+
import 'package:catalog/catalog.dart';
3+
import 'package:catalog/widgets/app_text_fields.dart';
4+
import 'package:flutter/material.dart';
5+
import 'package:flutter_screenutil/flutter_screenutil.dart';
6+
import 'package:gallery/catalog/catalog_scaffold_screen.dart';
7+
8+
@RoutePage()
9+
class CatalogTextFieldsScreen extends StatefulWidget {
10+
const CatalogTextFieldsScreen({super.key});
11+
12+
@override
13+
State<CatalogTextFieldsScreen> createState() =>
14+
_CatalogTextFieldsScreenState();
15+
}
16+
17+
class _CatalogTextFieldsScreenState extends State<CatalogTextFieldsScreen> {
18+
int _characterCount = 0;
19+
final labelTextController = TextEditingController();
20+
final textAreaTextController = TextEditingController();
21+
22+
@override
23+
Widget build(BuildContext context) => CatalogScaffold(
24+
title: 'TEXT FIELDS',
25+
child: Container(
26+
margin: const EdgeInsets.all(20),
27+
child: Column(
28+
children: [
29+
AppTextField(
30+
controller: labelTextController,
31+
labelText: 'Label',
32+
helperText: 'Helper text',
33+
hintText: 'Text',
34+
suffixIcon: Icon(
35+
Icons.close,
36+
color: context.theme.colors.textColor.shade200,
37+
),
38+
prefixIcon: Icon(
39+
Icons.close,
40+
color: context.theme.colors.textColor.shade200,
41+
),
42+
keyboardType: TextInputType.emailAddress,
43+
),
44+
SizedBox(height: 10.h),
45+
AppTextField(
46+
keyboardType: TextInputType.multiline,
47+
controller: textAreaTextController,
48+
maxLength: 100,
49+
labelText: 'Label',
50+
hintText: 'Text',
51+
currentLength: _characterCount,
52+
onChange: (value) {
53+
setState(() {
54+
_characterCount = value.length;
55+
});
56+
},
57+
minLines: 8,
58+
maxLines: 10,
59+
),
60+
SizedBox(height: 10.h),
61+
],
62+
),
63+
),
64+
);
65+
}

catalog/gallery/lib/catalog/catalog_text_fields_screen.dart

-15
This file was deleted.

catalog/gallery/lib/main/catalog_main_screen.dart

+20
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ enum _CatalogScreen {
4040
textFields,
4141
colors,
4242
typography,
43+
dropdown,
44+
dialog,
45+
radioButtons,
46+
checkbox,
4347
}
4448

4549
extension _CatalogScreenExtensions on _CatalogScreen {
@@ -53,6 +57,14 @@ extension _CatalogScreenExtensions on _CatalogScreen {
5357
return 'Colors';
5458
case _CatalogScreen.typography:
5559
return 'Typography';
60+
case _CatalogScreen.dropdown:
61+
return 'Dropdown';
62+
case _CatalogScreen.dialog:
63+
return 'Dialog';
64+
case _CatalogScreen.radioButtons:
65+
return 'Radio Buttons';
66+
case _CatalogScreen.checkbox:
67+
return 'Checkbox';
5668
}
5769
}
5870

@@ -66,6 +78,14 @@ extension _CatalogScreenExtensions on _CatalogScreen {
6678
return const CatalogAppColorsRoute();
6779
case _CatalogScreen.typography:
6880
return const CatalogAppTypographyRoute();
81+
case _CatalogScreen.dropdown:
82+
return const CatalogDropdownRoute();
83+
case _CatalogScreen.dialog:
84+
return const CatalogDialogRoute();
85+
case _CatalogScreen.radioButtons:
86+
return const CatalogAppRadioButtonRoute();
87+
case _CatalogScreen.checkbox:
88+
return const CatalogAppCheckboxRoute();
6989
}
7090
}
7191
}

catalog/gallery/lib/router/catalog_router.dart

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import 'package:auto_route/auto_route.dart';
22
import 'package:gallery/catalog/catalog_app_button_screen.dart';
33
import 'package:gallery/catalog/catalog_app_colors_screen.dart';
4+
import 'package:gallery/catalog/catalog_app_radio_button.dart';
45
import 'package:gallery/catalog/catalog_app_typography_screen.dart';
5-
import 'package:gallery/catalog/catalog_text_fields_screen.dart';
6+
import 'package:gallery/catalog/catalog_app_checkbox.dart';
7+
import 'package:gallery/catalog/catalog_app_dropdown_screen.dart';
8+
import 'package:gallery/catalog/catalog_app_text_fields_screen.dart';
9+
import 'package:gallery/catalog/catalog_app_dialog.dart';
610
import 'package:gallery/main/catalog_main_screen.dart';
711

812
part 'catalog_router.gr.dart';
@@ -21,5 +25,9 @@ class CatalogRouter extends _$CatalogRouter {
2125
AutoRoute(page: CatalogTextFieldsRoute.page),
2226
AutoRoute(page: CatalogAppColorsRoute.page),
2327
AutoRoute(page: CatalogAppTypographyRoute.page),
28+
AutoRoute(page: CatalogDropdownRoute.page),
29+
AutoRoute(page: CatalogDialogRoute.page),
30+
AutoRoute(page: CatalogAppRadioButtonRoute.page),
31+
AutoRoute(page: CatalogAppCheckboxRoute.page),
2432
];
2533
}

catalog/gallery/lib/router/catalog_router.gr.dart

+80
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

catalog/gallery/pubspec.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ dev_dependencies:
3636
build_runner: 2.4.6
3737
lints: 3.0.0
3838

39+
flutter:
40+
uses-material-design: true
41+
3942
flutter_launcher_icons:
4043
android: true
4144
ios: true

0 commit comments

Comments
 (0)