Skip to content

Commit

Permalink
add TapRegion
Browse files Browse the repository at this point in the history
  • Loading branch information
toly1994328 committed Dec 13, 2024
1 parent 0a0642e commit 736385b
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 43 deletions.
Binary file modified assets/flutter.db
Binary file not shown.
1 change: 0 additions & 1 deletion lib/src/navigation/view/desktop/menu_bar_leading.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class MenuBarLeading extends StatelessWidget {
children: [
GestureDetector(
onDoubleTap: (){
Navigator.of(context).push(MaterialPageRoute(builder: (_)=>CarouselNode2()));
},
child: CircleImage(
image: AssetImage('assets/images/icon_head.webp'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"id": 280,
"name": "TapRegion",
"localName": "点击范围",
"info": "能够检测内部或外部点击回调的组件,通过 groupId 可以多个区域视为一体。",
"lever": 4,
"family": 2,
"linkIds": [
146,
54
],
"nodes": [
{
"file": "node1.dart",
"name": "监听点击组件内部和外部",
"desc": [
"通过 Localizations.localeOf(context) 可以根据上下文获取最近上层的 Localizations 组件存储的 Locale 数据信息。"
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'package:flutter/material.dart';

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

@override
State<TapRegionDemo1> createState() => _TapRegionDemo1State();
}

class _TapRegionDemo1State extends State<TapRegionDemo1> {
String info = 'Tap any where';

@override
Widget build(BuildContext context) {
return TapRegion(
onTapOutside: _onTapOutside,
onTapInside: _onTapInside,
child: Container(
alignment: Alignment.center,
height: 64,
width: 160,
color: isOut ? Colors.grey : Colors.blue,
child: Text(
info,
textAlign: TextAlign.center,
style: const TextStyle(color: Colors.white),
),
),
);
}

bool get isOut => info.contains('TapOutside');

void _onTapOutside(PointerDownEvent event) {
setState(() {
info = "TapOutside:\n${event.position}";
});
}

void _onTapInside(PointerDownEvent event) {
setState(() {
info = "TapInside:\n${event.position}";
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"id": 290,
"name": "Localizations",
"localName": "国际化",
"info": "为子树节点提供国际化资源,底层依赖 InheritedWidget 实现。 MaterialApp 内部已集成该组件,其 locale 和 delegates 参数最终用于该组件。",
"lever": 4,
"family": 1,
"linkIds": [
65,
346
],
"nodes": [
{
"file": "node1.dart",
"name": "获取当前语言",
"desc": [
"通过 Localizations.localeOf(context) 可以根据上下文获取最近上层的 Localizations 组件存储的 Locale 数据信息。"
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:flutter/material.dart';

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

@override
Widget build(BuildContext context) {
Locale locale = Localizations.localeOf(context);
return Text('Locale: ${locale.toString()}');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
library render_object_widget;


export '../MultiChildRenderObjectWidget/Flex/node_01.dart';
export '../MultiChildRenderObjectWidget/Flex/node_02.dart';
export '../MultiChildRenderObjectWidget/Flex/node_03.dart';
export '../MultiChildRenderObjectWidget/Flex/node_04.dart';
export '../MultiChildRenderObjectWidget/Flex/node_05.dart';

export '../MultiChildRenderObjectWidget/Flow/node_01.dart';
export '../MultiChildRenderObjectWidget/Flow/node_02.dart';
export '../MultiChildRenderObjectWidget/RichText/node1_base.dart';
export '../MultiChildRenderObjectWidget/RichText/node2_widget.dart';
export '../MultiChildRenderObjectWidget/Stack/node1_base.dart';
export '../MultiChildRenderObjectWidget/Stack/node2_positioned.dart';
export '../MultiChildRenderObjectWidget/Wrap/node1_base.dart';
export '../MultiChildRenderObjectWidget/Wrap/node2_alignment.dart';
export '../MultiChildRenderObjectWidget/Wrap/node3_crossAxisAlignment.dart';
export '../MultiChildRenderObjectWidget/Wrap/node4_textDirection.dart';
export '../MultiChildRenderObjectWidget/Wrap/node5_verticalDirection.dart';
export '../MultiChildRenderObjectWidget/Column/node_01.dart';
export '../MultiChildRenderObjectWidget/IndexedStack/node1_base.dart';
export '../MultiChildRenderObjectWidget/Row/node1_base.dart';
export '../MultiChildRenderObjectWidget/CustomMultiChildLayout/node_01.dart';
export '../MultiChildRenderObjectWidget/Viewport/node1_base.dart';
export '../MultiChildRenderObjectWidget/ListBody/node1_base.dart';
export '../MultiChildRenderObjectWidget/ShrinkWrappingViewport/node1_base.dart';
export '../MultiChildRenderObjectWidget/NestedScrollViewViewport/node1_base.dart';
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
library render_object_widget;


export '../MultiChildRenderObjectWidget/Flex/node_01.dart';
export '../MultiChildRenderObjectWidget/Flex/node_02.dart';
export '../MultiChildRenderObjectWidget/Flex/node_03.dart';
export '../MultiChildRenderObjectWidget/Flex/node_04.dart';
export '../MultiChildRenderObjectWidget/Flex/node_05.dart';

export '../MultiChildRenderObjectWidget/Flow/node_01.dart';
export '../MultiChildRenderObjectWidget/Flow/node_02.dart';
export '../MultiChildRenderObjectWidget/RichText/node1_base.dart';
export '../MultiChildRenderObjectWidget/RichText/node2_widget.dart';
export '../MultiChildRenderObjectWidget/Stack/node1_base.dart';
export '../MultiChildRenderObjectWidget/Stack/node2_positioned.dart';
export '../MultiChildRenderObjectWidget/Wrap/node1_base.dart';
export '../MultiChildRenderObjectWidget/Wrap/node2_alignment.dart';
export '../MultiChildRenderObjectWidget/Wrap/node3_crossAxisAlignment.dart';
export '../MultiChildRenderObjectWidget/Wrap/node4_textDirection.dart';
export '../MultiChildRenderObjectWidget/Wrap/node5_verticalDirection.dart';
export '../MultiChildRenderObjectWidget/Column/node_01.dart';
export '../MultiChildRenderObjectWidget/IndexedStack/node1_base.dart';
export '../MultiChildRenderObjectWidget/Row/node1_base.dart';
export '../MultiChildRenderObjectWidget/CustomMultiChildLayout/node_01.dart';
export '../MultiChildRenderObjectWidget/Viewport/node1_base.dart';
export '../MultiChildRenderObjectWidget/ListBody/node1_base.dart';
export '../MultiChildRenderObjectWidget/ShrinkWrappingViewport/node1_base.dart';
export '../MultiChildRenderObjectWidget/NestedScrollViewViewport/node1_base.dart';

export '../SingleChildRenderObjectWidget/Align/node1_base.dart';
export '../SingleChildRenderObjectWidget/Align/node2_other.dart';
export '../SingleChildRenderObjectWidget/CustomSingleChildLayout/node1_base.dart';
Expand Down Expand Up @@ -97,4 +70,5 @@ export '../SingleChildRenderObjectWidget/IntrinsicWidth/node1_base.dart';
export '../SingleChildRenderObjectWidget/PhysicalShape/node1_base.dart';
export '../SingleChildRenderObjectWidget/ImageFiltered/node1_blur.dart';
export '../SingleChildRenderObjectWidget/ImageFiltered/node2_color.dart';
export '../SingleChildRenderObjectWidget/ImageFiltered/node3_matrix.dart';
export '../SingleChildRenderObjectWidget/ImageFiltered/node3_matrix.dart';
export '../SingleChildRenderObjectWidget/TapRegion/node1.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export '../StatefulWidget/TextButton/node1_base.dart';
export '../StatefulWidget/TextButton/node2_style.dart';
export '../StatefulWidget/FilledButton/node1.dart';
export '../StatefulWidget/FilledButton/node2.dart';
export '../StatefulWidget/Localizations/node1.dart';

export '../StatefulWidget/ElevatedButton/node1_base.dart';
export '../StatefulWidget/ElevatedButton/node2_style.dart';
Expand Down
18 changes: 11 additions & 7 deletions modules/widget_system/widgets/lib/node_display_map.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import 'package:flutter/cupertino.dart';
import 'exp/other_unit.dart';
import 'exp/proxy_unit.dart';
import 'exp/render_object_unit.dart';
import 'exp/sliver_unit.dart';
import 'exp/stateful_unit.dart';
import 'exp/stateless_unit.dart';
import 'exp/Other.dart';
import 'exp/ProxyWidget.dart';
import 'exp/MultiChildRenderObjectWidget.dart';
import 'exp/SingleChildRenderObjectWidget.dart';
import 'exp/Sliver.dart';
import 'exp/StatefulWidget.dart';
import 'exp/StatelessWidget.dart';


Widget mapNodeDisplay(int widgetId, int nodePriority) {
String name = '$widgetId#$nodePriority';

return switch (name) {
'96#0' => const ColumnNode1(),
'96#0' => const ColumnNode1(),
'341#0' => const CustomMultiChildLayoutNode1(),
'94#0' => const FlexNode1(),
'94#1' => const FlexNode2(),
Expand Down Expand Up @@ -133,6 +135,7 @@ Widget mapNodeDisplay(int widgetId, int nodePriority) {
'294#0' => const SizeChangedLayoutNotifierDemo(),
'76#0' => const CustomSizedBox(),
'84#0' => const CustomSizedOverflowBox(),
'280#0' => const TapRegionDemo1(),
'78#0' => const SkewTransform(),
'78#1' => const TranslationTransform(),
'78#2' => const ScaleTransform(),
Expand Down Expand Up @@ -277,6 +280,7 @@ Widget mapNodeDisplay(int widgetId, int nodePriority) {
'145#0' => const CustomLicensePage(),
'47#0' => const CustomLinearProgressIndicator(),
'179#0' => const CustomListWheelScrollView(),
'290#0' => const LocalizationsDemo1(),
'105#0' => const CustomLongPressDraggable(),
'160#0' => const CustomMaterial(),
'160#1' => const ShapeMaterial(),
Expand Down
7 changes: 0 additions & 7 deletions modules/widget_system/widgets/lib/widgets.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
library widgets;

export 'node_display_map.dart';

export 'exp/other_unit.dart';
export 'exp/proxy_unit.dart';
export 'exp/render_object_unit.dart' hide Box50,CornerCustomMultiChildLayout,CornerType;
export 'exp/sliver_unit.dart';
export 'exp/stateful_unit.dart' hide ListModel;
export 'exp/stateless_unit.dart';

0 comments on commit 736385b

Please sign in to comment.