Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
gm_flutter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林生雨
gm_flutter
Commits
f4082c9c
Commit
f4082c9c
authored
Jun 30, 2020
by
朱翠翠
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目说明页面
parent
e7c84792
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
290 additions
and
23 deletions
+290
-23
ClueRouter.dart
lib/ClueModel/ClueRouter.dart
+5
-6
ClueRouterImpl.dart
lib/ClueModel/ClueRouterImpl.dart
+8
-4
ProjectDetailsItemView.dart
...ClueModel/page/ProjectDetails/ProjectDetailsItemView.dart
+66
-0
ProjectDetailsModel.dart
lib/ClueModel/page/ProjectDetails/ProjectDetailsModel.dart
+31
-0
ProjectDetailsPage.dart
lib/ClueModel/page/ProjectDetails/ProjectDetailsPage.dart
+65
-0
ClueApi.dart
lib/ClueModel/server/api/ClueApi.dart
+6
-3
ClueApi.serv.dart
lib/ClueModel/server/api/ClueApi.serv.dart
+21
-0
ProjectDetailsItem.dart
lib/ClueModel/server/entity/ProjectDetailsItem.dart
+76
-0
main.dart
lib/main.dart
+12
-10
No files found.
lib/ClueModel/ClueRouter.dart
View file @
f4082c9c
...
...
@@ -2,12 +2,12 @@
* @author lsy
* @date 2020/6/24
**/
import
'package:flutter/widgets.dart'
;
import
'package:flutter_common/Annotations/RouterBaser.dart'
;
import
'package:flutter_common/Annotations/anno/Router.dart'
;
import
'package:flutter_common/Annotations/anno/RouterCenter.dart'
;
import
'package:gm_flutter/ClueModel/ClueRouterImpl.dart'
;
@Router
(
"ClueRouter"
,
ClueRouterImpl
,
true
)
abstract
class
ClueRouter
implements
RouterBaser
{
}
\ No newline at end of file
@Router
(
"ClueRouter"
,
ClueRouterImpl
,
true
)
abstract
class
ClueRouter
implements
RouterBaser
{
Widget
getProjectDetailsPage
();
}
lib/ClueModel/ClueRouterImpl.dart
View file @
f4082c9c
...
...
@@ -2,8 +2,13 @@
* @author lsy
* @date 2020/6/24
**/
import
'package:flutter/src/widgets/framework.dart'
;
import
'package:gm_flutter/ClueModel/ClueRouter.dart'
;
import
'package:gm_flutter/ClueModel/page/ProjectDetails/ProjectDetailsPage.dart'
;
class
ClueRouterImpl
implements
ClueRouter
{
}
\ No newline at end of file
class
ClueRouterImpl
implements
ClueRouter
{
@override
Widget
getProjectDetailsPage
()
{
return
ProjectDetailsPage
();
}
}
lib/ClueModel/page/ProjectDetails/ProjectDetailsItemView.dart
0 → 100644
View file @
f4082c9c
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/ProjectDetailsItem.dart'
;
class
ProjectDetailsItemView
extends
StatelessWidget
{
Groups
listData
;
ProjectDetailsItemView
(
this
.
listData
);
@override
Widget
build
(
BuildContext
context
)
{
List
<
Widget
>
tiles
=
[];
for
(
var
item
in
listData
.
attrs
)
{
tiles
.
add
(
getItem
(
item
));
}
var
row
=
Row
(
children:
<
Widget
>[
Container
(
padding:
EdgeInsets
.
only
(
top:
8.0
,
bottom:
8.0
,
left:
20
),
child:
Text
(
listData
.
name
,
style:
TextStyle
(
color:
Color
(
0xFF000000
),
fontSize:
15.0
,
),
),
),
Column
(
children:
tiles
,
)
],
);
return
Container
(
margin:
EdgeInsets
.
only
(
bottom:
5
,
left:
20
),
child:
row
,
);
}
getItem
(
Attrs
attrs
)
{
var
row
=
Container
(
margin:
EdgeInsets
.
only
(
bottom:
25
),
child:
Row
(
children:
<
Widget
>[
Text
(
attrs
.
name
,
style:
TextStyle
(
color:
Color
(
0xFF999999
),
fontSize:
13.0
,
),
),
Text
(
attrs
.
value
,
style:
TextStyle
(
color:
Color
(
0xFF282828
),
fontSize:
14.0
,
),
maxLines:
1
,
),
],
),
);
return
Container
(
child:
row
,
);
}
}
lib/ClueModel/page/ProjectDetails/ProjectDetailsModel.dart
0 → 100644
View file @
f4082c9c
import
'package:flutter_common/commonModel/live/BaseModel.dart'
;
import
'package:flutter_common/commonModel/live/LiveData.dart'
;
import
'package:gm_flutter/ClueModel/server/api/ClueApi.serv.dart'
;
import
'package:gm_flutter/commonModel/GMBase.dart'
;
import
'package:gm_flutter/commonModel/rx/RxDispose.dart'
;
import
'../../server/entity/ProjectDetailsItem.dart'
;
class
ProjectDetailsModel
extends
BaseModel
{
LiveData
<
ProjectDetailsItem
>
liveData
=
LiveData
();
RxDispose
rxDispose
=
RxDispose
();
void
init
()
{
ClueApiImpl
.
getInstance
()
.
getProjectDetails
(
DioUtil
.
getInstance
().
getDio
(),
123
)
.
listen
((
event
)
{
// if(event.error==0){
// event.data;
// liveData.notifyView(event);
// }
})
.
addToDispose
(
rxDispose
)
.
onError
((
err
)
{});
}
@override
void
dispose
()
{
liveData
.
dispost
();
rxDispose
.
dispose
();
}
}
lib/ClueModel/page/ProjectDetails/ProjectDetailsPage.dart
0 → 100644
View file @
f4082c9c
/*
* @author zcc
* @date 2020/6/29
**/
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:gm_flutter/ClueModel/page/ProjectDetails/ProjectDetailsItemView.dart'
;
import
'package:gm_flutter/ClueModel/page/ProjectDetails/ProjectDetailsModel.dart'
;
import
'package:gm_flutter/commonModel/base/BaseComponent.dart'
;
import
'package:gm_flutter/commonModel/base/BaseState.dart'
;
import
'../../server/entity/ProjectDetailsItem.dart'
;
class
ProjectDetailsPage
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
=>
ProjectDetailsState
();
}
class
ProjectDetailsState
extends
BaseState
<
ProjectDetailsPage
>
{
ProjectDetailsModel
_model
=
new
ProjectDetailsModel
();
@override
void
initState
()
{
super
.
initState
();
}
@override
void
dispose
()
{
_model
.
dispose
();
super
.
dispose
();
}
@override
Widget
buildItem
(
BuildContext
context
)
{}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
"项目说明"
),
),
body:
Center
(
child:
getBody
(),
),
);
}
getBody
()
{
return
StreamBuilder
(
stream:
_model
.
liveData
.
stream
,
initialData:
ProjectDetailsItem
(),
builder:
(
c
,
data
)
{
ProjectDetailsItem
item
=
data
.
data
;
if
(
data
==
null
||
item
==
null
||
item
.
groups
==
null
)
{
return
loadingItem
();
}
return
ListView
.
builder
(
itemCount:
item
.
groups
.
length
,
itemBuilder:
(
BuildContext
context
,
int
position
)
{
return
ProjectDetailsItemView
(
item
.
groups
[
position
]);
});
},
);
}
}
lib/ClueModel/server/api/ClueApi.dart
View file @
f4082c9c
...
...
@@ -3,8 +3,12 @@
* @date 2020/6/28
**/
import
'package:flutter_common/Annotations/anno/Get.dart'
;
import
'package:flutter_common/Annotations/anno/Query.dart'
;
import
'package:flutter_common/Annotations/anno/ServiceCenter.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/ProjectDetailsItem.dart'
;
@ServiceCenter
()
class
ClueApi
{
}
\ No newline at end of file
abstract
class
ClueApi
{
@Get
(
"/api/janus/plans/<:plan_id>/detail"
)
ProjectDetailsItem
getProjectDetails
(
@Query
(
"plan_id"
)
int
plan_id
);
}
lib/ClueModel/server/api/ClueApi.serv.dart
View file @
f4082c9c
...
...
@@ -14,6 +14,8 @@ import 'package:dio/dio.dart';
import
'package:flutter/foundation.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/ProjectDetailsItem.dart'
;
const
bool
inProduction
=
const
bool
.
fromEnvironment
(
"dart.vm.product"
);
class
ClueApiImpl
{
...
...
@@ -30,6 +32,21 @@ class ClueApiImpl {
return
_instance
;
}
Stream
<
ProjectDetailsItem
>
getProjectDetails
(
Dio
_dio
,
int
plan_id
)
{
return
Stream
.
fromFuture
(
get
(
_dio
,
'/api/janus/plans/<:plan_id>/detail'
,
data:
{
'plan_id'
:
plan_id
,
})).
flatMap
((
value
)
{
if
(
value
!=
null
&&
(
value
.
statusCode
>=
200
&&
value
.
statusCode
<
300
))
{
return
Stream
.
fromFuture
(
compute
(
parseProjectDetailsItem
,
value
.
toString
()));
}
else
{
throw
Exception
(
"--未知网络错误--"
);
}
});
}
///==================base method==================
Future
<
Response
>
get
(
Dio
_dio
,
url
,
{
data
,
options
,
cancelToken
})
async
{
...
...
@@ -166,3 +183,7 @@ class ClueApiImpl {
return
reason
;
}
}
ProjectDetailsItem
parseProjectDetailsItem
(
String
value
)
{
return
ProjectDetailsItem
.
fromJson
(
json
.
decode
(
value
));
}
lib/ClueModel/server/entity/ProjectDetailsItem.dart
0 → 100644
View file @
f4082c9c
import
'package:flutter_common/Annotations/anno/ServerEntity.dart'
;
class
ProjectDetailsItem
{
String
name
;
List
<
Groups
>
groups
;
ProjectDetailsItem
({
this
.
name
,
this
.
groups
});
ProjectDetailsItem
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
name
=
json
[
'name'
];
if
(
json
[
'groups'
]
!=
null
)
{
groups
=
new
List
<
Groups
>();
json
[
'groups'
].
forEach
((
v
)
{
groups
.
add
(
new
Groups
.
fromJson
(
v
));
});
}
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'name'
]
=
this
.
name
;
if
(
this
.
groups
!=
null
)
{
data
[
'groups'
]
=
this
.
groups
.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
return
data
;
}
}
class
Groups
{
String
name
;
List
<
Attrs
>
attrs
;
Groups
(
String
s
,
List
<
Attrs
>
list
,
{
this
.
name
,
this
.
attrs
});
Groups
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
name
=
json
[
'name'
];
if
(
json
[
'attrs'
]
!=
null
)
{
attrs
=
new
List
<
Attrs
>();
json
[
'attrs'
].
forEach
((
v
)
{
attrs
.
add
(
new
Attrs
.
fromJson
(
v
));
});
}
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'name'
]
=
this
.
name
;
if
(
this
.
attrs
!=
null
)
{
data
[
'attrs'
]
=
this
.
attrs
.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
return
data
;
}
}
class
Attrs
{
int
id
;
String
name
;
String
value
;
Attrs
({
this
.
id
,
this
.
name
,
this
.
value
});
Attrs
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
name
=
json
[
'name'
];
value
=
json
[
'value'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'name'
]
=
this
.
name
;
data
[
'value'
]
=
this
.
value
;
return
data
;
}
}
lib/main.dart
View file @
f4082c9c
...
...
@@ -11,6 +11,7 @@ import 'DemoPage.dart';
import
'DemoPage1.dart'
;
import
'commonModel/base/BaseUtil.dart'
;
import
'commonModel/nav/NavigationService.dart'
;
import
'main.mark.dart'
;
NavigationService
navigationService
;
...
...
@@ -70,16 +71,17 @@ class MyApp extends State<MyAppWidget> {
return
MaterialApp
(
theme:
ThemeData
(),
builder:
FlutterBoost
.
init
(
postPush:
_onRoutePushed
),
home:
isDebug
?
Container
(
color:
Colors
.
red
,
)
:
Container
(
color:
Colors
.
white
,
child:
Center
(
child:
loadingItem
(),
),
)
home:
RouterCenterImpl
().
findClueRouter
().
getProjectDetailsPage
(),
// home: isDebug
// ? Container(
// color: Colors.red,
// )
// : Container(
// color: Colors.white,
// child: Center(
// child: loadingItem(),
// ),
// )
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment