Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sunarya-thito committed Feb 28, 2025
1 parent ac25eb0 commit 3caa65f
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 162 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:shadcn_flutter/shadcn_flutter.dart';

class DatePickerExample3 extends StatefulWidget {
const DatePickerExample3({super.key});

@override
State<DatePickerExample3> createState() => _DatePickerExample3State();
}

class _DatePickerExample3State extends State<DatePickerExample3> {
DateTime? _value;
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
DateInput(
initialValue: DateTime.now(),
onChanged: (value) {
setState(() {
_value = value;
});
},
),
Gap(20),
Text('Selected date: $_value'),
],
);
}
}
7 changes: 7 additions & 0 deletions docs/lib/pages/docs/components/date_picker_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:shadcn_flutter/shadcn_flutter.dart';

import '../../widget_usage_example.dart';
import '../component_page.dart';
import 'date_picker/date_picker_example_3.dart';

class DatePickerExample extends StatelessWidget {
const DatePickerExample({super.key});
Expand All @@ -27,6 +28,12 @@ class DatePickerExample extends StatelessWidget {
'lib/pages/docs/components/date_picker/date_picker_example_2.dart',
child: DatePickerExample2(),
),
WidgetUsageExample(
title: 'Date Input Example',
path:
'lib/pages/docs/components/date_picker/date_picker_example_3.dart',
child: DatePickerExample3(),
),
],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,31 @@ class FormattedInputExample1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FormattedInput(
parts: [
InputPart.editable(length: 2, width: 40),
InputPart.static('/'),
InputPart.editable(length: 2, width: 40),
InputPart.static('/'),
InputPart.editable(length: 4, width: 60),
],
trailing: IconButton.text(
density: ButtonDensity.compact,
icon: Icon(Icons.calendar_month),
onPressed: () {},
),
initialValue: FormattedValue(
[
'12',
'/',
'34',
'/',
'5678',
],
),
onChanged: (value) {
if (value == null) {
return;
}
List<String> parts = [];
for (FormattedValuePart part in value.parts) {
parts.add(part.value ?? '');
}
print(parts.join('/'));
},
initialValue: FormattedValue([
InputPart.editable(length: 2, width: 40, placeholder: Text('MM'))
.withValue('01'),
InputPart.static('/'),
InputPart.editable(length: 2, width: 40, placeholder: Text('DD'))
.withValue('02'),
InputPart.static('/'),
InputPart.editable(length: 4, width: 60, placeholder: Text('YYYY'))
.withValue('2021'),
]),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,81 +17,17 @@ class _MultiSelectExample1State extends State<MultiSelectExample1> {
},
popup: SelectPopup(
items: SelectItemList(children: [
SelectGroup(
headers: [
SelectLabel(
child: Text('Apple'),
),
],
children: [
SelectItemButton(
value: 'Red Apple',
child: Text('Red Apple'),
),
SelectItemButton(
value: 'Green Apple',
child: Text('Green Apple'),
),
],
SelectItemButton(
value: 'Apple',
child: Text('Apple'),
),
SelectGroup(
headers: [
SelectLabel(
child: Text('Banana'),
),
],
children: [
SelectItemButton(
value: 'Yellow Banana',
child: Text('Yellow Banana'),
),
SelectItemButton(
value: 'Brown Banana',
child: Text('Brown Banana'),
),
],
SelectItemButton(
value: 'Banana',
child: Text('Banana'),
),
SelectGroup(
headers: [
SelectLabel(
child: Text('Lemon'),
),
],
children: [
SelectItemButton(
value: 'Yellow Lemon',
child: Text('Yellow Lemon'),
),
SelectItemButton(
value: 'Green Lemon',
child: Text('Green Lemon'),
),
],
),
SelectGroup(
headers: [
SelectLabel(
child: Text('Tomato'),
),
],
children: [
SelectItemButton(
value: 'Red Tomato',
child: Text('Red'),
),
SelectItemButton(
value: 'Green Tomato',
child: Text('Green'),
),
SelectItemButton(
value: 'Yellow Tomato',
child: Text('Yellow'),
),
SelectItemButton(
value: 'Brown Tomato',
child: Text('Brown'),
),
],
SelectItemButton(
value: 'Cherry',
child: Text('Cherry'),
),
])),
onChanged: (value) {
Expand Down
82 changes: 9 additions & 73 deletions docs/lib/pages/docs/components/select/select_example_1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,81 +29,17 @@ class _SelectExample1State extends State<SelectExample1> {
popup: const SelectPopup(
items: SelectItemList(
children: [
SelectGroup(
headers: [
SelectLabel(
child: Text('Apple'),
),
],
children: [
SelectItemButton(
value: 'Red Apple',
child: Text('Red Apple'),
),
SelectItemButton(
value: 'Green Apple',
child: Text('Green Apple'),
),
],
SelectItemButton(
value: 'Apple',
child: Text('Apple'),
),
SelectGroup(
headers: [
SelectLabel(
child: Text('Banana'),
),
],
children: [
SelectItemButton(
value: 'Yellow Banana',
child: Text('Yellow Banana'),
),
SelectItemButton(
value: 'Brown Banana',
child: Text('Brown Banana'),
),
],
SelectItemButton(
value: 'Banana',
child: Text('Banana'),
),
SelectGroup(
headers: [
SelectLabel(
child: Text('Lemon'),
),
],
children: [
SelectItemButton(
value: 'Yellow Lemon',
child: Text('Yellow Lemon'),
),
SelectItemButton(
value: 'Green Lemon',
child: Text('Green Lemon'),
),
],
),
SelectGroup(
headers: [
SelectLabel(
child: Text('Tomato'),
),
],
children: [
SelectItemButton(
value: 'Red Tomato',
child: Text('Red'),
),
SelectItemButton(
value: 'Green Tomato',
child: Text('Green'),
),
SelectItemButton(
value: 'Yellow Tomato',
child: Text('Yellow'),
),
SelectItemButton(
value: 'Brown Tomato',
child: Text('Brown'),
),
],
SelectItemButton(
value: 'Cherry',
child: Text('Cherry'),
),
],
),
Expand Down

0 comments on commit 3caa65f

Please sign in to comment.