Skip to content

Commit 1fd99fc

Browse files
committed
完成命名路由配置及文章详情页
1 parent 4868e11 commit 1fd99fc

File tree

12 files changed

+158
-29
lines changed

12 files changed

+158
-29
lines changed
8.54 MB
Binary file not shown.
8.31 MB
Binary file not shown.
8.04 MB
Binary file not shown.
8.11 MB
Binary file not shown.
8.09 MB
Binary file not shown.
7.45 MB
Binary file not shown.

assets/fonts/Noto_Sans_SC/OFL.txt

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
2+
This license is copied below, and is also available with a FAQ at:
3+
http://scripts.sil.org/OFL
4+
5+
6+
-----------------------------------------------------------
7+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
8+
-----------------------------------------------------------
9+
10+
PREAMBLE
11+
The goals of the Open Font License (OFL) are to stimulate worldwide
12+
development of collaborative font projects, to support the font creation
13+
efforts of academic and linguistic communities, and to provide a free and
14+
open framework in which fonts may be shared and improved in partnership
15+
with others.
16+
17+
The OFL allows the licensed fonts to be used, studied, modified and
18+
redistributed freely as long as they are not sold by themselves. The
19+
fonts, including any derivative works, can be bundled, embedded,
20+
redistributed and/or sold with any software provided that any reserved
21+
names are not used by derivative works. The fonts and derivatives,
22+
however, cannot be released under any other type of license. The
23+
requirement for fonts to remain under this license does not apply
24+
to any document created using the fonts or their derivatives.
25+
26+
DEFINITIONS
27+
"Font Software" refers to the set of files released by the Copyright
28+
Holder(s) under this license and clearly marked as such. This may
29+
include source files, build scripts and documentation.
30+
31+
"Reserved Font Name" refers to any names specified as such after the
32+
copyright statement(s).
33+
34+
"Original Version" refers to the collection of Font Software components as
35+
distributed by the Copyright Holder(s).
36+
37+
"Modified Version" refers to any derivative made by adding to, deleting,
38+
or substituting -- in part or in whole -- any of the components of the
39+
Original Version, by changing formats or by porting the Font Software to a
40+
new environment.
41+
42+
"Author" refers to any designer, engineer, programmer, technical
43+
writer or other person who contributed to the Font Software.
44+
45+
PERMISSION & CONDITIONS
46+
Permission is hereby granted, free of charge, to any person obtaining
47+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
48+
redistribute, and sell modified and unmodified copies of the Font
49+
Software, subject to the following conditions:
50+
51+
1) Neither the Font Software nor any of its individual components,
52+
in Original or Modified Versions, may be sold by itself.
53+
54+
2) Original or Modified Versions of the Font Software may be bundled,
55+
redistributed and/or sold with any software, provided that each copy
56+
contains the above copyright notice and this license. These can be
57+
included either as stand-alone text files, human-readable headers or
58+
in the appropriate machine-readable metadata fields within text or
59+
binary files as long as those fields can be easily viewed by the user.
60+
61+
3) No Modified Version of the Font Software may use the Reserved Font
62+
Name(s) unless explicit written permission is granted by the corresponding
63+
Copyright Holder. This restriction only applies to the primary font name as
64+
presented to the users.
65+
66+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
67+
Software shall not be used to promote, endorse or advertise any
68+
Modified Version, except to acknowledge the contribution(s) of the
69+
Copyright Holder(s) and the Author(s) or with their explicit written
70+
permission.
71+
72+
5) The Font Software, modified or unmodified, in part or in whole,
73+
must be distributed entirely under this license, and must not be
74+
distributed under any other license. The requirement for fonts to
75+
remain under this license does not apply to any document created
76+
using the Font Software.
77+
78+
TERMINATION
79+
This license becomes null and void if any of the above conditions are
80+
not met.
81+
82+
DISCLAIMER
83+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
84+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
85+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
86+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
87+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
88+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
89+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
90+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
91+
OTHER DEALINGS IN THE FONT SOFTWARE.

lib/config.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,21 @@ const primaryColor = const MaterialColor(
1818
},
1919
);
2020

21+
const lightGreen = const MaterialColor(0xFFE8F5E9, <int, Color>{
22+
50: Color(0xFFE8F5E9),
23+
100: Color(0xFFC8E6C9),
24+
200: Color(0xFFA5D6A7),
25+
300: Color(0xFF81C784),
26+
400: Color(0xFF66BB6A),
27+
500: Color(0xFF4CAF50),
28+
600: Color(0xFF43A047),
29+
700: Color(0xFF388E3C),
30+
800: Color(0xFF2E7D32),
31+
900: Color(0xFF1B5E20),
32+
});
33+
34+
const lightGrey = const MaterialColor(0xf7f7f7f7, <int, Color>{
35+
50: Color(0xf7f7f7f7),
36+
});
37+
2138
const baseUrl = 'http://192.168.1.135:3001';

lib/main.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'package:blog_flutter/widgets/article.dart';
2+
import 'package:blog_flutter/widgets/home.dart';
13
import 'package:flutter/material.dart';
24
import './widgets/home.dart';
35
import 'config.dart';
@@ -13,6 +15,10 @@ class App extends StatelessWidget {
1315
theme: ThemeData(
1416
primarySwatch: primaryColor,
1517
),
18+
routes: {
19+
'/home': (context) => HomeWidget(),
20+
'/article': (context) => ArticleWidget()
21+
},
1622
home: HomeWidget());
1723
}
1824
}

lib/widgets/article.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import 'package:blog_flutter/config.dart';
2+
import 'package:flutter/material.dart';
3+
4+
class ArticleWidget extends StatelessWidget {
5+
final article;
6+
7+
ArticleWidget({Key key, @required this.article}) : super(key: key);
8+
9+
@override
10+
Widget build(BuildContext context) {
11+
final Map params = ModalRoute.of(context).settings.arguments;
12+
13+
return Scaffold(
14+
appBar: AppBar(title: Text(params['title'])),
15+
body: Container(
16+
height: MediaQuery.of(context).size.height,
17+
padding: EdgeInsets.fromLTRB(15, 10, 10, 10),
18+
decoration: BoxDecoration(color: lightGreen),
19+
child: SingleChildScrollView(
20+
child: Text(
21+
'\t\t\t\t\t\t\t' + params['content'],
22+
style: TextStyle(
23+
fontSize: 18,
24+
fontFamily: 'NotoSansSC',
25+
height: 1.6,
26+
letterSpacing: 1),
27+
)),
28+
),
29+
);
30+
}
31+
}

lib/widgets/home.dart

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,6 @@ class HomeWidget extends StatefulWidget {
88
}
99

1010
class HomeWidgetState extends State<HomeWidget> {
11-
static const lightGreen = const MaterialColor(0xFFE8F5E9, <int, Color>{
12-
50: Color(0xFFE8F5E9),
13-
100: Color(0xFFC8E6C9),
14-
200: Color(0xFFA5D6A7),
15-
300: Color(0xFF81C784),
16-
400: Color(0xFF66BB6A),
17-
500: Color(0xFF4CAF50),
18-
600: Color(0xFF43A047),
19-
700: Color(0xFF388E3C),
20-
800: Color(0xFF2E7D32),
21-
900: Color(0xFF1B5E20),
22-
});
23-
static const lightGrey = const MaterialColor(0xf7f7f7, <int, Color>{
24-
50: Color(0xf7f7f7),
25-
100: Color(0xFFC8E6C9),
26-
200: Color(0xFFA5D6A7),
27-
300: Color(0xFF81C784),
28-
400: Color(0xFF66BB6A),
29-
500: Color(0xFF4CAF50),
30-
600: Color(0xFF43A047),
31-
700: Color(0xFF388E3C),
32-
800: Color(0xFF2E7D32),
33-
900: Color(0xFF1B5E20),
34-
});
3511
var _articles = <dynamic>[];
3612
var _start = 0, _limit = 10, _total = 0;
3713

@@ -41,12 +17,7 @@ class HomeWidgetState extends State<HomeWidget> {
4117
_getArticles();
4218
}
4319

44-
void _onTapArticle(index) {
45-
print(index);
46-
}
47-
4820
void _getArticles() async {
49-
print('$_start ~ $_limit');
5021
var response = await http
5122
.get('/articles', queryParameters: {'start': _start, 'limit': _limit});
5223
setState(() {
@@ -55,6 +26,10 @@ class HomeWidgetState extends State<HomeWidget> {
5526
});
5627
}
5728

29+
void _onTapArticle(index) {
30+
Navigator.of(context).pushNamed('/article', arguments: _articles[index]);
31+
}
32+
5833
@override
5934
Widget build(BuildContext context) {
6035
return Scaffold(

pubspec.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ flutter:
4747
# the material Icons class.
4848
uses-material-design: true
4949

50+
fonts:
51+
- family: NotoSansSC
52+
fonts:
53+
- asset: assets/fonts/Noto_Sans_SC/NotoSansSC-Regular.otf
54+
- asset: assets/fonts/Noto_Sans_SC/NotoSansSC-Medium.otf
55+
- weight: 500
56+
- asset: assets/fonts/Noto_Sans_SC/NotoSansSC-Bold.otf
57+
- weight: 600
58+
5059
# To add assets to your application, add an assets section, like this:
5160
# assets:
5261
# - images/a_dot_burr.jpeg

0 commit comments

Comments
 (0)