Skip to content

Commit

Permalink
菜单卡片
Browse files Browse the repository at this point in the history
  • Loading branch information
lemos1235 committed Oct 8, 2022
1 parent 3ed25b7 commit 24f1300
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 29 deletions.
3 changes: 2 additions & 1 deletion lib/pages/user/user_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:icoffee/widgets/gf_action_tile.dart';
import 'package:icoffee/widgets/gf_menu_card.dart';

/// "我-编辑资料"页
class UserDetailPage extends StatefulWidget {
Expand Down Expand Up @@ -65,7 +66,7 @@ class _UserDetailPageState extends State<UserDetailPage> {
),
),
),
GFActionCard(
GFMenuCard(
children: [
BrnTextInputFormItem(
title: "昵称",
Expand Down
5 changes: 3 additions & 2 deletions lib/pages/user/user_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:go_router/go_router.dart';
import 'package:icoffee/app_routes.dart';
import 'package:icoffee/constants/app_colors.dart';
import 'package:icoffee/widgets/gf_action_tile.dart';
import 'package:icoffee/widgets/gf_menu_card.dart';

/// "我"页
class UserPage extends StatefulWidget {
Expand Down Expand Up @@ -92,7 +93,7 @@ class _UserPageState extends State<UserPage> {
Widget _vipRow() {
return Column(
children: [
GFActionCard(
GFMenuCard(
children: [
GFActionTile(
title: "我的会员",
Expand All @@ -112,7 +113,7 @@ class _UserPageState extends State<UserPage> {
Widget _toolsRow() {
return Column(
children: [
GFActionCard(
GFMenuCard(
children: [
GFActionTile(
title: "智能电子秤",
Expand Down
27 changes: 1 addition & 26 deletions lib/widgets/gf_action_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,8 @@
// [Author] lg (https://github.com/lemos1235)
// [Date] 2022/10/4
//
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';

class GFActionCard extends StatelessWidget {
const GFActionCard({super.key, required this.children});

final List<Widget> children;

@override
Widget build(BuildContext context) {
List<Widget> widgets = [];
children.forEachIndexed((index, element) {
if (index != 0 && index != children.length) {
widgets.add(
Divider(indent: 12, endIndent: 12, height: 1, color: Color(0xFFECECEC)),
);
}
widgets.add(element);
});
return Container(
child: Column(
children: widgets,
),
);
}
}

class GFActionTile extends StatelessWidget {
const GFActionTile({super.key, required this.title, this.onTap, this.trailingText});

Expand All @@ -53,7 +28,7 @@ class GFActionTile extends StatelessWidget {
Widget _rowWidget(BuildContext context) {
return Container(
color: Colors.white,
padding: EdgeInsets.only(left: 18, right: 23, top: 18, bottom: 18),
padding: EdgeInsets.only(left: 20, right: 20, top: 14, bottom: 14),
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
Expand Down
31 changes: 31 additions & 0 deletions lib/widgets/gf_menu_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// [Author] lg (https://github.com/lemos1235)
// [Date] 10/8/2022
//
import 'package:flutter/material.dart';

class GFMenuCard extends StatelessWidget {
const GFMenuCard({super.key, required this.children});

final List<Widget> children;

@override
Widget build(BuildContext context) {
List<Widget> widgets = [];
var len = children.length;
for (int i = 0; i < len; i++) {
final item = children[i];
if (i != 0 && i != len) {
widgets.add(
Divider(indent: 12, endIndent: 12, height: 1, color: Color(0xFFECECEC)),
);
}
widgets.add(item);
}
return Container(
child: Column(
children: widgets,
),
);
}
}

0 comments on commit 24f1300

Please sign in to comment.