Skip to content

Commit

Permalink
overview display
Browse files Browse the repository at this point in the history
  • Loading branch information
toly1994328 committed Oct 13, 2024
1 parent 671fab1 commit 1b3f86e
Show file tree
Hide file tree
Showing 8 changed files with 589 additions and 199 deletions.
35 changes: 26 additions & 9 deletions lib/incubator/components/layout/grid_layout/wrap_grid_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import 'package:flutter/material.dart';

enum ExpandType {
spacing,
width,
width, // 宽度延伸
limitWidth, // 限制最大宽度为 measureWidth
}

class Wrap$ extends StatelessWidget {
final double maxWidth;
final double measureWidth;
final double height;
final double spacing;
final double runSpacing;
Expand All @@ -19,7 +20,7 @@ class Wrap$ extends StatelessWidget {

const Wrap$({
super.key,
required this.maxWidth,
required this.measureWidth,
required this.height,
this.alignment = Alignment.center,
this.spacing = 0,
Expand All @@ -37,17 +38,23 @@ class Wrap$ extends StatelessWidget {
padding: padding ?? EdgeInsets.symmetric(horizontal: spacing),
child: LayoutBuilder(
builder: (ctx, cts) {
int count = (cts.maxWidth + spacing) ~/ maxWidth;

int count = (cts.maxWidth + spacing) ~/ measureWidth;
double effectSpacing = spacing;
count = min(count, children.length);
double width = (cts.maxWidth / count) - spacing * (count - 1);
if (expandType == ExpandType.width) {
width = min(width, maxWidth);
if(expandType!=ExpandType.width){
count = min(count, children.length);

}
// double width = (cts.maxWidth / count) - spacing * (count - 1);
double width = (cts.maxWidth-spacing * (count - 1))/count ;
if (expandType == ExpandType.limitWidth) {
width = min(width, measureWidth);
}
if (expandType == ExpandType.spacing) {
width = maxWidth;
width = measureWidth;
effectSpacing = (cts.maxWidth - width * count) / (count);
}

return Wrap(
runSpacing: runSpacing,
spacing: effectSpacing,
Expand All @@ -64,4 +71,14 @@ class Wrap$ extends StatelessWidget {
),
);
}

/// 以 [measureWidth] 度量,得到每行承载的个数
///
// (double,double) calcSize(double layoutWidth){
// int count = (layoutWidth + spacing) ~/ measureWidth;
// double effectSpacing = spacing;
// count = min(count, children.length);
// double width = (layoutWidth / count) - spacing * (count - 1);
// }

}
6 changes: 3 additions & 3 deletions lib/navigation/menu/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ Map<String, dynamic> get dataMenus => {
// 'icon': Icons.text_fields,
},
{
'path': '/slideshow',
'label': 'Slideshow',
'subtitle': '幻灯片',
'path': '/carousel',
'label': 'Carousel',
'subtitle': '走马灯',
'isFlutter': true,
'tag': '新'
// 'icon': Icons.text_fields,
Expand Down
4 changes: 3 additions & 1 deletion lib/navigation/router/widgets_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import '../../view/widgets/overview/overview_page.dart';
import '../../view/widgets/widgets_page.dart';
import '../view/empty404/widget404.dart';


RouteBase get widgetsRoute => ShellRoute(
builder: (BuildContext context, GoRouterState state, Widget child) {
return WidgetNavigationScope(
Expand Down Expand Up @@ -72,7 +73,8 @@ RouteBase get widgetsRoute => ShellRoute(
_customRoute('card'),
_customRoute('tag'),
_customRoute('slideshow'),
]), GoRoute(
]),
GoRoute(
path: 'advance',
builder: (BuildContext context, GoRouterState state) {
return EcologicalPage();
Expand Down
9 changes: 7 additions & 2 deletions lib/navigation/view/app_navigation_scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@ import 'package:flutter/material.dart';

import '../../view/home_page/home_nav_bar.dart';

class AppNavigationScope extends StatelessWidget{
class AppNavigationScope extends StatefulWidget{
final Widget child;
const AppNavigationScope({super.key, required this.child});

@override
State<AppNavigationScope> createState() => _AppNavigationScopeState();
}

class _AppNavigationScopeState extends State<AppNavigationScope> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: HomeNavBar(),
body: Column(
children: [
Divider(),
Expanded(child: child),
Expanded(child: widget.child),
],
),
);
Expand Down
Loading

0 comments on commit 1b3f86e

Please sign in to comment.