Modify:文件名称的大小写规范

This commit is contained in:
ryan730
2019-01-12 18:09:40 +08:00
parent ae1e1d9b9a
commit e4df84c0be
17 changed files with 130 additions and 16 deletions

View File

@ -0,0 +1,127 @@
import 'package:flutter/material.dart';
import '../model/cat.dart';
import '../common/widget_name_to_icon.dart';
import '../components/widget_item_container.dart';
class CateCard extends StatefulWidget {
final Cat category;
CateCard({@required this.category});
@override
_CateCardState createState() => _CateCardState();
}
class _CateCardState extends State<CateCard> {
// 一级菜单目录下的二级Cat集合
List<Cat> _firstChildList = new List();
CatControlModel catControl = new CatControlModel();
@override
void initState() {
super.initState();
getFirstChildCategoriesByParentId();
}
// 获取一层目录下的二级内容
getFirstChildCategoriesByParentId() async {
int parentId = widget.category.id;
// 构建查询条件
Cat childCateCondition = new Cat(parentId: parentId);
List<Cat> list = await catControl.getList(childCateCondition);
if (list.isNotEmpty&&list.length>=1 && this.mounted) {
setState(() {
_firstChildList = list;
});
}
}
@override
Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
widget.category.name = widget.category.name.replaceFirst(
//首字母转为大写
widget.category.name.substring(0, 1),
widget.category.name.substring(0, 1).toUpperCase());
return Container(
width: screenWidth,
padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 10.0),
child: Stack(
children: <Widget>[
Container(
width: screenWidth - 20,
margin: const EdgeInsets.only(top: 30.0, bottom: 0.0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(4.0),
),
child: Column(
children: <Widget>[
Container(
width: screenWidth - 20,
padding: const EdgeInsets.only(left: 65.0, top: 3.0),
height: 30.0,
child: Text(
widget.category.name,
style: TextStyle(
color: Theme.of(context).primaryColor,
fontSize: 18.0,
),
),
),
_buildWidgetContainer(),
],
),
),
Positioned(
left: 0.0,
top: 0.0,
child: Container(
height: 60.0,
width: 60.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(30.0),
),
child: Center(
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(23.0),
),
height: 46.0,
width: 46.0,
child: Icon(
WidgetName2Icon.icons[widget.category.name],
color: Colors.white,
size: 30.0,
),
),
),
),
)
],
),
);
}
Widget _buildWidgetContainer() {
if (this._firstChildList.length == 0) {
return Container();
}
return Container(
padding: const EdgeInsets.only(bottom: 10.0, top: 5.0),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/paimaiLogo.png'),
alignment: Alignment.bottomRight
),
),
child: WidgetItemContainer(
categories: this._firstChildList,
columnCount: 3,
isWidgetPoint:false
),
);
}
}

View File

@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_rookie_book/views/Detail.dart';
import 'package:flutter_rookie_book/views/detail.dart';

View File

@ -0,0 +1,51 @@
/**
* Created with Android Studio.
* User: 一晟
* Date: 2019/1/5
* Time: 下午10:20
* email: zhu.yan@alibaba-inc.com
* tartget: FirstPageItem
*/
import '../common/Util.dart';
class FirstPageItem {
bool hot;
String isCollection;
String tag;
String username;
int collectionCount;
int commentCount;
String title;
String createdTime;
String detailUrl;
FirstPageItem(
{this.hot,
this.tag,
this.username,
this.collectionCount,
this.createdTime,
this.commentCount,
this.title,
this.detailUrl,
this.isCollection});
factory FirstPageItem.fromJson(Map<String, dynamic> json) {
String _tag = '';
if(json['tags'].length>0){
_tag = '${json['tags'][0]['title']}/';
}
return FirstPageItem(
hot: json['hot'],
collectionCount: json['collectionCount'],
commentCount: json['commentsCount'],
tag: '$_tag${json['category']['name']}',
username: json['user']['username'],
createdTime: Util.getTimeDuration(json['createdAt']),
title: json['title'],
detailUrl: json['originalUrl'],
isCollection: json['type'] ,
);
}
}

View File

@ -0,0 +1,63 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import './home_banner.dart';
import '../model/story.dart';
import 'package:url_launcher/url_launcher.dart';
class Pagination extends StatelessWidget {
static final String routeName = '/material/page-selector';
static final List<Icon> icons = <Icon>[
const Icon(Icons.event, semanticLabel: 'Event'),
const Icon(Icons.home, semanticLabel: 'Home'),
const Icon(Icons.android, semanticLabel: 'Android'),
const Icon(Icons.alarm, semanticLabel: 'Alarm'),
const Icon(Icons.face, semanticLabel: 'Face'),
const Icon(Icons.language, semanticLabel: 'Language'),
];
final List<StoryModel> bannerStories = [];
final List<dynamic> arr = [
{'image': 'https://img.alicdn.com/tfs/TB1W4hMAwHqK1RjSZJnXXbNLpXa-519-260.jpg', 'type': 0, 'id': 9695909, 'url': 'https://www.zhihu.com/question/294145797/answer/551162834', 'title': '为什么阿里巴巴、腾讯和 Google 之类的企业都在使用 Flutter 开发 App'},
{'image': 'https://img.alicdn.com/tfs/TB1XmFIApzqK1RjSZSgXXcpAVXa-720-338.jpg', 'type': 0, 'id': 9695859, 'url': 'https://zhuanlan.zhihu.com/p/51696594', 'title': 'Flutter 1.0 正式发布: Google 的便携 UI 工具包'},
{'image': 'https://img.alicdn.com/tfs/TB1mClCABLoK1RjSZFuXXXn0XXa-600-362.jpg', 'type': 0, 'id': 96956491409, 'url':'https://zhuanlan.zhihu.com/p/53497167','title': 'Flutter 示范应用现已开源 — 万物起源(The History of Everything)'},
{'image': 'https://img.alicdn.com/tfs/TB1fXxIAAvoK1RjSZFNXXcxMVXa-600-362.jpg', 'type': 0, 'id': 9695816, 'url': 'https://mp.weixin.qq.com/s?__biz=MzAwODY4OTk2Mg==&mid=2652048101&idx=1&sn=20296088e4bd8ca33c5c9991167d9f7d&chksm=808caaa0b7fb23b65c0e5806209f8d86da6732f3a00a70353f3606018339518b0a8656f14dc5&mpshare=1&scene=2&srcid=0106SZapVysZdIS6Oc5AhNH6&from=timeline&ascene=2&devicetype=android-27&version=27000038&nettype=WIFI&abtest_cookie=BQABAAgACgALABMAFAAFAJ2GHgAjlx4AV5keAJuZHgCcmR4AAAA%3D&lang=zh_CN&pass_ticket=4K1%2FUpsxP4suPj2iubR17wbAP7r9LW9iYrPAC2dppTqv7j7JO5FWMXtcKeBRxueV&wx_header=1', 'title': 'Flutter 与 Material Design 双剑合璧,助您构建精美应用'}
];
void _launchURL(String url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
List<Widget> _pageSelector(BuildContext context) {
List<Widget> list = [];
/// super.initState();
arr.forEach((item) {
bannerStories.add(StoryModel.fromJson(item));
});
if (arr.length > 0) {
list.add(HomeBanner(bannerStories, (story) {
_launchURL('${story.url}');
}));
}
return list;
}
@override
Widget build(BuildContext context) {
return
Column(
//physics: AlwaysScrollableScrollPhysics(),
//padding: EdgeInsets.only(),
children: _pageSelector(context)
);
}
}

View File

@ -2,7 +2,7 @@
* @author 一凨
*/
import 'package:flutter/material.dart';
import '../common/Style.dart';
import '../common/style.dart';
import '../common/widget_name_to_icon.dart';
class WidgetItem extends StatelessWidget {