Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

chore: example rewrite #381

Merged
merged 2 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example/lib/colors.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'src/colors/colors_view.dart';
1 change: 1 addition & 0 deletions example/lib/containers.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'src/containers/containers_view.dart';
1 change: 1 addition & 0 deletions example/lib/controls.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'src/controls/controls_view.dart';
5 changes: 5 additions & 0 deletions example/lib/example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export 'containers.dart';
export 'controls.dart';
export 'home.dart';
export 'textfields.dart';
export 'colors.dart';
1 change: 1 addition & 0 deletions example/lib/fonts.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'src/fonts/fonts_view.dart';
2 changes: 2 additions & 0 deletions example/lib/home.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export 'src/home/color_disk.dart';
export 'src/home/home_page.dart';
3 changes: 2 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:yaru/yaru.dart';
import 'package:yaru_example/view/home_page.dart';

import 'home.dart';

void main() {
runApp(const MyApp());
Expand Down
2 changes: 2 additions & 0 deletions example/lib/src/constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const kWrapSpacing = 20.0;
const kWrapPadding = 20.0;
89 changes: 89 additions & 0 deletions example/lib/src/containers/containers_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import 'package:flutter/material.dart';
import 'package:yaru_example/src/constants.dart';

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

@override
State<ContainersView> createState() => _ContainersViewState();
}

class _ContainersViewState extends State<ContainersView> {
var _elevation = 2.0;
var _inDialog = true;

@override
Widget build(BuildContext context) {
final card = Card(
elevation: _elevation,
child: const SizedBox(
height: 150,
width: 200,
child: Center(
child: Text('Card'),
),
),
);

final slider = Row(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(left: 10),
child: Text(_elevation.toStringAsFixed(2)),
),
Slider(
value: _elevation,
max: 10,
min: 0,
onChanged: (value) => setState(() => _elevation = value),
),
],
);

final containerWithBorder = Padding(
padding: const EdgeInsets.all(12.0),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(color: Theme.of(context).dividerColor),
),
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 70, vertical: 50),
child: Text('Just a border'),
),
),
);

final children = [
card,
slider,
containerWithBorder,
];

return SizedBox(
width: 400,
child: Column(
children: [
const SizedBox(
height: kWrapSpacing,
),
Switch(
value: _inDialog,
onChanged: (v) => setState(
() => _inDialog = v,
),
),
if (_inDialog)
SimpleDialog(
shadowColor: Colors.black,
contentPadding: const EdgeInsets.all(kWrapSpacing),
children: children,
)
else
...children
],
),
);
}
}
78 changes: 78 additions & 0 deletions example/lib/src/controls/buttons.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import 'package:flutter/material.dart';
import 'package:yaru_example/src/constants.dart';

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

@override
State<Buttons> createState() => _ButtonsState();
}

class _ButtonsState extends State<Buttons> {
void incrementCounter() {
setState(() {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text('Yay! ❤️ for Yaru')));
});
}

@override
Widget build(BuildContext context) {
final buttons = <(Widget, Widget)>[
(
TextButton(
onPressed: () {},
child: const Text('Text'),
),
const TextButton(
onPressed: null,
autofocus: true,
child: Text('Text'),
),
),
(
OutlinedButton(
onPressed: () {},
child: const Text('Outlined'),
),
const OutlinedButton(
onPressed: null,
child: Text('Outlined'),
),
),
(
FilledButton(
onPressed: () {},
child: const Text('Filled'),
),
const FilledButton(
onPressed: null,
child: Text('Filled'),
),
),
(
ElevatedButton(
onPressed: () {},
child: const Text('Elevated'),
),
const ElevatedButton(
onPressed: null,
child: Text('Elevated'),
),
),
];

return Wrap(
direction: Axis.vertical,
spacing: kWrapSpacing,
runSpacing: kWrapSpacing,
children: [
for (final button in buttons)
Wrap(
spacing: kWrapSpacing,
children: [button.$1, button.$2],
)
],
);
}
}
41 changes: 41 additions & 0 deletions example/lib/src/controls/chips.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'package:flutter/material.dart';
import 'package:yaru_example/src/constants.dart';

class Chips extends StatelessWidget {
const Chips({super.key});

@override
Widget build(BuildContext context) {
return Wrap(
spacing: kWrapSpacing,
runSpacing: kWrapSpacing,
children: [
const Chip(label: Text('Ch-ch-ch-Chip n Dale ')),
Chip(
label: const Text('Rescue Rangers'),
onDeleted: () {},
),
const ChoiceChip(
label: Text('Ch-ch-ch-Chip n Dale '),
selected: false,
onSelected: null,
),
ChoiceChip(
label: const Text('When there s danger '),
selected: true,
onSelected: (value) {},
),
const ChoiceChip(
label: Text('No,no it never fails'),
selected: true,
onSelected: null,
),
ChoiceChip(
label: const Text('Once they re involved'),
selected: false,
onSelected: (value) {},
)
],
);
}
}
57 changes: 57 additions & 0 deletions example/lib/src/controls/controls_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'package:flutter/material.dart';
import 'package:yaru_example/src/controls/chips.dart';
import 'package:yaru_example/src/controls/fabs.dart';

import 'buttons.dart';
import 'progres.dart';
import 'toggleables.dart';

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

@override
State<ControlsView> createState() => _ControlsViewState();
}

class _ControlsViewState extends State<ControlsView>
with TickerProviderStateMixin {
late TabController tabController;
final items = const <(Widget, Widget)>[
(Tab(text: 'Buttons'), Buttons()),
(Tab(text: 'Fabs'), Fabs()),
(Tab(text: 'ToggleAbles'), ToggleAbles()),
(Tab(text: 'Chips'), Chips()),
(Tab(text: 'Progress'), Progress())
];

@override
void initState() {
tabController = TabController(length: items.length, vsync: this);
super.initState();
}

@override
Widget build(BuildContext context) {
return Column(
children: [
TabBar(
controller: tabController,
tabs: items.map((e) => e.$1).toList(),
),
Expanded(
child: TabBarView(
controller: tabController,
children: items
.map(
(e) => Padding(
padding: const EdgeInsets.all(20),
child: e.$2,
),
)
.toList(),
),
),
],
);
}
}
35 changes: 35 additions & 0 deletions example/lib/src/controls/fabs.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import 'package:flutter/material.dart';
import 'package:yaru_example/src/constants.dart';

class Fabs extends StatelessWidget {
const Fabs({super.key});

@override
Widget build(BuildContext context) {
void onPressed() => ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text('Yay! ❤️ for Yaru')));

return Wrap(
spacing: kWrapSpacing,
runSpacing: kWrapSpacing,
children: [
FloatingActionButton(
onPressed: onPressed,
child: const Icon(Icons.plus_one),
),
FloatingActionButton.extended(
onPressed: onPressed,
label: const Text('Yay! +1 ❤️ for Yaru'),
),
FloatingActionButton.small(
onPressed: onPressed,
child: const Icon(Icons.plus_one),
),
FloatingActionButton.large(
onPressed: onPressed,
child: const Icon(Icons.plus_one),
),
],
);
}
}
54 changes: 54 additions & 0 deletions example/lib/src/controls/progres.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import 'package:flutter/material.dart';
import 'package:yaru_example/src/constants.dart';

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

@override
State<Progress> createState() => _ProgressState();
}

class _ProgressState extends State<Progress> {
var _level = 1.0;
final _width = 300.0;
@override
Widget build(BuildContext context) {
final children = [
SizedBox(
width: _width,
child: LinearProgressIndicator(value: _level),
),
CircularProgressIndicator(value: _level),
SizedBox(width: _width, child: const LinearProgressIndicator()),
const CircularProgressIndicator(),
];

return Padding(
padding: const EdgeInsets.all(kWrapPadding),
child: Column(
children: [
SizedBox(
width: _width,
child: Slider(
value: _level,
max: 1,
min: 0,
onChanged: (value) => setState(() => _level = value),
),
),
const SizedBox(
height: kWrapSpacing,
),
Wrap(
spacing: kWrapSpacing,
runSpacing: kWrapSpacing,
crossAxisAlignment: WrapCrossAlignment.center,
direction: Axis.vertical,
verticalDirection: VerticalDirection.down,
children: children,
),
],
),
);
}
}
Loading
Loading