Skip to content

Commit

Permalink
feat(example): improve icon page (#856)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier authored Mar 2, 2024
1 parent 4e34861 commit bbe2184
Show file tree
Hide file tree
Showing 13 changed files with 203 additions and 176 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ on:
push:
branches:
- main
workflow_dispatch:

env:
FLUTTER_VERSION: 3.16.5
FLUTTER_VERSION: 3.16.9

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
- uses: subosito/flutter-action@v1
with:
channel: 'stable'
flutter-version: ${{env.FLUTTER_VERSION}}
- uses: bluefireteam/flutter-gh-pages@v7
with:
Expand Down
Binary file modified assets/yaru_icons.otf
Binary file not shown.
14 changes: 11 additions & 3 deletions example/lib/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ import 'package:yaru/yaru.dart';
import 'code_snippet_button.dart';
import 'example_model.dart';
import 'example_page_items.dart';
import 'pages/icons_page/provider/icon_view_model.dart';

class Example extends StatefulWidget {
// ignore: unused_element
const Example({super.key});

static Widget create(BuildContext context) {
return ChangeNotifierProvider<ExampleModel>(
create: (_) => ExampleModel(getService<Connectivity>()),
return MultiProvider(
providers: [
ChangeNotifierProvider<ExampleModel>(
create: (_) => ExampleModel(getService<Connectivity>()),
),
ChangeNotifierProvider(
create: (_) => IconViewModel(),
),
],
child: const Example(),
);
}
Expand Down Expand Up @@ -62,7 +70,7 @@ class _MasterDetailPage extends StatelessWidget {
length: pageItems.length,
tileBuilder: (context, index, selected, availableWidth) => YaruMasterTile(
leading: pageItems[index].iconBuilder(context, selected),
title: buildTitle(context, pageItems[index]),
title: Text(pageItems[index].title),
),
pageBuilder: (context, index) => YaruDetailPage(
appBar: YaruWindowTitleBar(
Expand Down
3 changes: 2 additions & 1 deletion example/lib/example_page_items.dart
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ final examplePageItems = <PageItem>[
),
PageItem(
title: 'YaruIcons',
titleBuilder: createIconsPageAppBar,
pageBuilder: (context) {
return IconsPage.create(context: context);
return const IconsPage();
},
iconBuilder: (context, selected) => selected
? const Icon(YaruIcons.placeholder_icon_filled)
Expand Down
2 changes: 2 additions & 0 deletions example/lib/pages/icons_page/common/clickable_icon.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:yaru/yaru.dart';

import '../icon_items.dart';
import 'icon_dialog.dart';
Expand All @@ -18,6 +19,7 @@ class ClickableIcon extends StatelessWidget {
return AspectRatio(
aspectRatio: 1,
child: InkWell(
borderRadius: BorderRadius.circular(kYaruButtonRadius),
onTap: () => showDialog(
context: context,
builder: (context) => IconDialog(
Expand Down
5 changes: 2 additions & 3 deletions example/lib/pages/icons_page/common/icon_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ class IconDialog extends StatelessWidget {
title: Text(beautifyIconName(iconItem.name)),
),
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
for (final size in _iconDialogSizes)
Padding(
Expand Down
7 changes: 6 additions & 1 deletion example/lib/pages/icons_page/common/icon_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ class IconGrid extends StatelessWidget {
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: iconSize * 1.5,
),
padding: const EdgeInsets.all(8),
padding: const EdgeInsets.only(
top: 10,
bottom: 20,
left: 20,
right: 20,
),
itemCount: iconItems.length,
itemBuilder: (context, index) {
return Tooltip(
Expand Down
61 changes: 31 additions & 30 deletions example/lib/pages/icons_page/common/icon_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,41 @@ class IconTable extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListView.builder(
padding: const EdgeInsets.all(16),
itemCount: iconItems.length,
itemBuilder: (context, index) => Column(
children: [
Row(
children: [
SizedBox.square(
dimension: iconSize * 1.5,
child: ClickableIcon(
iconItem: iconItems[index],
iconSize: iconSize,
itemBuilder: (context, index) {
return Column(
children: [
Row(
children: [
SizedBox.square(
dimension: iconSize * 1.5,
child: ClickableIcon(
iconItem: iconItems[index],
iconSize: iconSize,
),
),
),
const SizedBox(
width: 16,
),
Expanded(
child: SelectableText(
beautifyIconName(iconItems[index].name),
style: Theme.of(context).textTheme.bodySmall,
const SizedBox(
width: 16,
),
),
Expanded(
child: IconUsage(
usage: iconItems[index].usage,
label: false,
mainAxisAlignment: MainAxisAlignment.start,
Expanded(
child: SelectableText(
beautifyIconName(iconItems[index].name),
style: Theme.of(context).textTheme.bodySmall,
),
),
),
],
),
if (index < iconItems.length - 1) const Divider(),
],
),
Expanded(
child: IconUsage(
usage: iconItems[index].usage,
label: false,
mainAxisAlignment: MainAxisAlignment.start,
),
),
],
),
if (index < iconItems.length - 1) const Divider(),
],
);
},
);
}
}
23 changes: 14 additions & 9 deletions example/lib/pages/icons_page/common/icon_usage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,20 @@ class IconUsage extends StatelessWidget {
width: 8,
),
],
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
color: Theme.of(context).highlightColor,
),
child: SelectableText(
usage,
style: usageTextStyle,
Flexible(
child: Padding(
padding: const EdgeInsets.only(right: 20),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
color: Theme.of(context).highlightColor,
),
child: SelectableText(
usage,
style: usageTextStyle,
),
),
),
),
],
Expand Down
15 changes: 11 additions & 4 deletions example/lib/pages/icons_page/icon_items.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ final List<IconItem> _staticIconItems = [
IconItem(
name: iconName,
usage: 'YaruIcons.$iconName',
iconBuilder: (context, iconSize) => Icon(
YaruIcons.all[iconName]!,
size: iconSize,
),
iconBuilder: (context, iconSize) {
final data = YaruIcons.all[iconName];

if (data == null) {
return const Placeholder();
}
return Icon(
data,
size: iconSize,
);
},
),
];

Expand Down
Loading

0 comments on commit bbe2184

Please sign in to comment.