Skip to content

Commit

Permalink
[flutter_web] Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
chen56 committed Jun 14, 2024
1 parent 91c2b17 commit 2e0bfd4
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 91 deletions.
3 changes: 3 additions & 0 deletions notes/flutter_web/lib/assets.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ mixin AssetsMixin {
final Asset lib_routes_notes_pure_dart_exception_page_dart = Asset('lib/routes/notes/pure_dart/exception/page.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_ActionChip_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_ActionChip.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_ButtonStyleButton_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_ButtonStyleButton.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Feedback_RefreshIndicator_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Feedback_RefreshIndicator.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Navigation_BottomAppBar_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Navigation_BottomAppBar.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Navigation_Menu_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Navigation_Menu.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_DropdownMenu_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_DropdownMenu.dart');
Expand All @@ -113,6 +114,7 @@ mixin AssetsMixin {
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_showDateRangePicker_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_showDateRangePicker.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_CalendarDatePicker_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_CalendarDatePicker.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_TextField_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_TextField.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Feedback_ProgressIndicator_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Feedback_ProgressIndicator.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_showDatePicker_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_showDatePicker.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Navigation_SliverAppBar_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Navigation_SliverAppBar.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_Switch_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_Switch.dart');
Expand All @@ -123,6 +125,7 @@ mixin AssetsMixin {
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_FilterChip_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_FilterChip.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_FloatingActionButton_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_FloatingActionButton.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_CheckboxListTile_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_CheckboxListTile.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Feedback_SnackBar_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Feedback_SnackBar.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Navigation_NavigationBar_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Navigation_NavigationBar.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Spacer_Spacer_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Spacer_Spacer.dart');
final Asset lib_routes_notes_cheatsheets_widgets__examples_Form_Radio_dart = Asset('lib/routes/notes/cheatsheets/widgets/_examples/Form_Radio.dart');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import 'package:you_flutter/state.dart';

main() {
runApp(MaterialApp(home: Scaffold(body: Feedback_ProgressIndicator())));
}

// ignore: camel_case_types
class Feedback_ProgressIndicator extends StatelessWidget {
Feedback_ProgressIndicator({super.key});

final selected = false.signal();

@override
Widget build(BuildContext context) {
return Watch(builder: (context) {
return Row(children: [
IconButton(
isSelected: selected.value,
selectedIcon: const Icon(Icons.pause),
icon: const Icon(Icons.play_arrow),
onPressed: () {
selected.value = !selected.value;
},
),
CircularProgressIndicator(value: selected.value ? null : 0.9),
Expanded(
child: LinearProgressIndicator(value: selected.value ? null : 0.9),
),
]);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'package:flutter/material.dart';
import 'package:you_flutter/state.dart';

main() {
runApp(MaterialApp(home: Scaffold(body: Feedback_RefreshIndicator())));
}

// ignore: camel_case_types
class Feedback_RefreshIndicator extends StatelessWidget {
Feedback_RefreshIndicator({super.key});

final selected = false.signal();

@override
Widget build(BuildContext context) {
return Watch(
builder: (context) {
return Column(children: [
const Text("RefreshIndicator 下拉刷新(Pull down to refresh)"),
SizedBox(
height: 200,
child: RefreshIndicator(
onRefresh: () async {
selected.value = true;
await Future.delayed(const Duration(seconds: 3)); // mock delay
selected.value = false;
},
child: ListView.builder(
physics: const AlwaysScrollableScrollPhysics(),
itemCount: 5, // 示例数据数量
itemBuilder: (context, index) {
return ListTile(title: Text('Item ${index + 1}/5'));
},
),
),
),
]);
},
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';

main() {
runApp(const MaterialApp(home: Scaffold(body: Feedback_SnackBar())));
}

// ignore: camel_case_types
class Feedback_SnackBar extends StatelessWidget {
const Feedback_SnackBar({super.key});

@override
Widget build(BuildContext context) {
return TextButton(
onPressed: () {
final snackBar = SnackBar(
behavior: SnackBarBehavior.floating,
content: const Text('SnackBar'),
action: SnackBarAction(
label: 'Close',
onPressed: () {},
),
);

ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(snackBar);
},
child: const Text(
'SnackBar',
style: TextStyle(fontWeight: FontWeight.bold),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'package:flutter/material.dart';
import 'package:you_flutter/state.dart';

main() {
runApp(MaterialApp(home: Scaffold(body: Form_Switch())));
}

// ignore: camel_case_types
class Form_Switch extends StatelessWidget {
Form_Switch({super.key});

final Value<bool> switch1 = false.signal();
final Value<bool> switchListTile1 = false.signal();

@override
Widget build(BuildContext context) {
return Watch(
builder: (context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
const Text("Switch"),
Switch(value: switch1.value, onChanged: (value) => switch1.value = value),
Switch(value: switch1.value, onChanged: null),
const Divider(),
const Text("SwitchListTile"),
SwitchListTile(title: const Text("enable"), value: switchListTile1.value, onChanged: (value) => switchListTile1.value = value),
SwitchListTile(title: const Text("disable"), value: switchListTile1.value, onChanged: null),
],
);
},
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:you_flutter/state.dart';

main() {
runApp(MaterialApp(home: Scaffold(body: Form_TextField())));
}

// ignore: camel_case_types
class Form_TextField extends StatelessWidget {
Form_TextField({super.key});

@override
Widget build(BuildContext context) {
return Watch(
builder: (context) {
return const Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
TextField(
obscureText: true,
decoration: InputDecoration(border: OutlineInputBorder(), labelText: 'Password'),
),
SizedBox(height: 10),
TextField(
maxLength: 10,
maxLengthEnforcement: MaxLengthEnforcement.none,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: '手机号/Phone',
errorText: '手机号不能为空/phone should not empty',
),
),
SizedBox(height: 10),
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'disable ',
enabled: false,
),
),
],
);
},
);
}
}
88 changes: 10 additions & 78 deletions notes/flutter_web/lib/routes/notes/cheatsheets/widgets/page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_web/app.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Feedback_ProgressIndicator.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Feedback_RefreshIndicator.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Feedback_SnackBar.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_ActionChip.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_ButtonStyleButton.dart';
import 'package:flutter_web/routes/notes/cheatsheets/widgets/_examples/Form_CalendarDatePicker.dart';
Expand Down Expand Up @@ -87,19 +89,19 @@ void build(BuildContext context, Cell print) {
FlutterExample(title: "Switch", source: assets.lib_routes_notes_cheatsheets_widgets__examples_Form_Switch_dart, child: Form_Switch()),
FlutterExample(title: "TextField", source: assets.lib_routes_notes_cheatsheets_widgets__examples_Form_TextField_dart, child: Form_TextField()),
]),
Level1MasonryLayout(title: "text&info&tip", cellWidth: 300, children: [
FlutterExample(title: "Badge", child: textAndInfoAndTip.badgesCell()),
FlutterExample(title: "ProgressIndicator", child: textAndInfoAndTip.progressIndicatorCell()),
FlutterExample(title: "ProgressIndicator2", child: textAndInfoAndTip.progressIndicator2Cell()),
FlutterExample(title: "CircleAvatar", child: textAndInfoAndTip.circleAvatar()),
Level1MasonryLayout(title: "Feedback", cellWidth: 300, children: [
FlutterExample(title: "ProgressIndicator", source: assets.lib_routes_notes_cheatsheets_widgets__examples_Feedback_ProgressIndicator_dart, child: Feedback_ProgressIndicator()),
FlutterExample(title: "RefreshIndicator", source: assets.lib_routes_notes_cheatsheets_widgets__examples_Feedback_RefreshIndicator_dart, child: Feedback_RefreshIndicator()),
FlutterExample(title: "SnackBar", source: assets.lib_routes_notes_cheatsheets_widgets__examples_Feedback_SnackBar_dart, child: Feedback_SnackBar()),
]),
Level1MasonryLayout(title: "高级模版容器,Advanced template container", cellWidth: 500, children: [
FlutterExample(title: "SnackBar", child: advancedTemplateContainer.snackBarCell()),
Level1MasonryLayout(title: "Overlays", cellWidth: 500, children: [
FlutterExample(title: "dialog", child: advancedTemplateContainer.dialog()),
FlutterExample(title: "bottomSheet", child: advancedTemplateContainer.bottomSheetCell()),
]),
Level1MasonryLayout(title: "装饰器,Decorator", cellWidth: 500, children: [
FlutterExample(title: "Card", child: decorator.cardCell()),
FlutterExample(title: "Badge", child: textAndInfoAndTip.badgesCell()),
FlutterExample(title: "CircleAvatar", child: textAndInfoAndTip.circleAvatar()),
]),
],
);
Expand Down Expand Up @@ -133,79 +135,9 @@ class TextAndInfoAndTip {
),
]);
}

Widget progressIndicatorCell() {
final selected = false.signal();
return Watch(builder: (context) {
return Row(children: [
IconButton(
isSelected: selected.value,
selectedIcon: const Icon(Icons.pause),
icon: const Icon(Icons.play_arrow),
onPressed: () {
selected.value = !selected.value;
},
),
CircularProgressIndicator(value: selected.value ? null : 0.9),
Expanded(
child: LinearProgressIndicator(value: selected.value ? null : 0.9),
),
]);
});
}

Widget progressIndicator2Cell() {
final selected = false.signal();
return Watch(
builder: (context) {
return Column(children: [
const Text("RefreshIndicator 下拉刷新(Pull down to refresh)"),
SizedBox(
height: 200,
child: RefreshIndicator(
onRefresh: () async {
selected.value = true;
await Future.delayed(const Duration(seconds: 3)); // mock delay
selected.value = false;
},
child: ListView.builder(
physics: const AlwaysScrollableScrollPhysics(),
itemCount: 5, // 示例数据数量
itemBuilder: (context, index) {
return ListTile(title: Text('Item ${index + 1}/5'));
},
),
),
),
]);
},
);
}
}

class AdvancedTemplateContainer {
Widget snackBarCell() {
return Builder(
builder: (context) => TextButton(
onPressed: () {
final snackBar = SnackBar(
behavior: SnackBarBehavior.floating,
content: const Text('SnackBar'),
action: SnackBarAction(
label: 'Close',
onPressed: () {},
),
);

ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(snackBar);
},
child: const Text(
'SnackBar',
style: TextStyle(fontWeight: FontWeight.bold),
),
));
}

Widget bottomSheetCell() {
Value<PersistentBottomSheetController?> bottomSheetController = (null as PersistentBottomSheetController?).signal();
Expand Down
31 changes: 18 additions & 13 deletions notes/flutter_web/lib/routes/notes/note.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@

### 装饰器

- 增强
- **简介**: 装饰器指外观样式或特性增强
- **简介**: 装饰器指附加的外观样式或特性增强
- 增强&包边&轮廓
- **BoxDecoration**:指定颜色、背景图片、边框`BoxBorder`
- **PhysicalModel**:用于给其子 Widget 添加物理外观属性,如阴影、边界和背景色等,从而使得 UI 具有更加丰富的视觉效果和质感。它主要用于实现Material设计中的“ elevation”(即阴影效果)和颜色叠加效果。
- 与 Card 相比,PhysicalModel 提供了更多的自定义选项,比如可以自定义阴影颜色,而不仅仅是依赖主题。
Expand All @@ -167,6 +167,8 @@
- **InkWell**
- **Card**: 虽然不是纯粹的布局组件,但因其提供了统一的矩形框样式和阴影效果,常用于构建卡片式的布局单元,特别是在列表和网格布局中。
- 【原理】内部包了个`Material`
- **Badge** : A badge's label conveys a small amount of information about its child, like a count or status
- 【原理】[api-Badges](https://api.flutter.dev/flutter/material/Badge-class.html)

- 隐藏&可见性
- **Opacity**: 是一种可以改变其子组件透明度的布局组件。它并不会影响子组件的实际尺寸和布局,而是控制子组件的内容可视性。
Expand Down Expand Up @@ -246,7 +248,7 @@
- **Icon** 图标
- Image

### button&input&form
### form&button&input

- **Button**
- **ButtonStyleButton**
Expand Down Expand Up @@ -282,21 +284,24 @@
- **YearPicker** The year picker widget is rarely used directly. Instead, consider using [CalendarDatePicker], or [showDatePicker] which create full date pickers.
- **showDatePicker** 弹出日期选择器Dialog

### Text&信息&提示
### Text

- **Text**
- **Text.rich**
- RichText
- **TextSelectionToolbar**
- Markdown
- SelectionArea 可选择界面一整个区域的文本
- DefaultTextStyle
- 进度条Progress indicators
- CircularProgressIndicator
- LinearProgressIndicator
- Badges [api-Badges](https://api.flutter.dev/flutter/material/Badge-class.html)
- **Tooltip**
- **SnackBar**
- **Markdown**
- **SelectionArea** 可选择界面一整个区域的文本
- **DefaultTextStyle**

### Feedback

- **ProgressIndicator** 进度指示器的抽象类
- **CircularProgressIndicator** 圆形的进度指示器,通常用于表示不确定的等待时间,即你不知道任务何时完成的情况。这个组件展示为一个旋转的环形动画,没有具体的进度百分比显示。适用于页面加载、数据获取等需要等待但不明确等待时长的场景。
- **LinearProgressIndicator** 线性的进度条。用于展示任务完成的百分比,与CircularProgressIndicator不同,它能明确显示任务完成的具体进度,因此非常适合于上传、下载或者其他有明确进度的任务。用户可以通过进度条的填充长度直观了解任务的完成情况
- **RefreshIndicator** 用于实现“下拉刷新”功能的交互。当用户在滚动列表的顶部向下滑动时,会显示一个通常为圆形的进度指示器(默认是CircularProgressIndicator),表明应用正在刷新数据。此组件通常包裹在可滚动的Widget(如ListView)外面,自动处理下拉手势检测、显示刷新指示器以及在数据刷新完成后隐藏指示器。
- **Tooltip** 用于为其他widgets提供悬停时的文本提示信息。当用户将鼠标指针(在桌面设备上)或触摸并停留(在触摸屏设备上)在一个带有Tooltip的widget上时,会显示一个包含说明性文字的弹出框。
- **SnackBar** 一种轻量级的反馈机制,用于在屏幕底部短暂显示信息,以通知用户操作的结果或其他非关键信息,比如成功保存、删除某项、或简单的警告信息。
- 【原理】ScaffoldMessenger.of(context).showSnackBar()

### 滚动scrolling
Expand Down

0 comments on commit 2e0bfd4

Please sign in to comment.