Ver código fonte

更新设置

tags/0.0.1
Weller 4 anos atrás
pai
commit
93f6719b21
9 arquivos alterados com 262 adições e 4 exclusões
  1. BIN
     
  2. +0
    -1
      .dart_tool/build_resolvers/sdk.sum.deps
  3. +1
    -1
      .dart_tool/package_config.json
  4. +34
    -0
      lib/pages/setting_page/models/setting_page_style_item_model.dart
  5. +28
    -0
      lib/pages/setting_page/models/setting_page_style_item_model.g.dart
  6. +51
    -0
      lib/pages/setting_page/models/setting_page_style_model.dart
  7. +111
    -1
      lib/pages/setting_page/setting_page.dart
  8. +36
    -0
      lib/pages/setting_page/setting_page_bloc.dart
  9. +1
    -1
      lib/widgets/mine/mine_nav/mine_nav.dart

+ 0
- 1
.dart_tool/build_resolvers/sdk.sum.deps Ver arquivo

@@ -1 +0,0 @@
{"sdk":"2.7.2 (Mon Mar 23 22:11:27 2020 +0100) on \"macos_x64\"","analyzer":"/Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/analyzer-0.39.14","build_resolvers":"/Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/build_resolvers-1.3.11"}

+ 1
- 1
.dart_tool/package_config.json Ver arquivo

@@ -770,7 +770,7 @@
"languageVersion": "2.1"
}
],
"generated": "2020-09-21T03:19:08.272955Z",
"generated": "2020-09-22T07:54:03.242397Z",
"generator": "pub",
"generatorVersion": "2.7.2"
}

+ 34
- 0
lib/pages/setting_page/models/setting_page_style_item_model.dart Ver arquivo

@@ -0,0 +1,34 @@
import 'package:json_annotation/json_annotation.dart';

part 'setting_page_style_item_model.g.dart';

@JsonSerializable()
class SettingPageStyleItemModel extends Object {
@JsonKey(name: 'name')
String name;

@JsonKey(name: 'name_color')
String nameColor;

@JsonKey(name: 'desc')
String desc;

@JsonKey(name: 'desc_color')
String descColor;

@JsonKey(name: 'skip_identifier')
String skipIdentifier;

SettingPageStyleItemModel(
this.name,
this.nameColor,
this.desc,
this.descColor,
this.skipIdentifier,
);

factory SettingPageStyleItemModel.fromJson(Map<String, dynamic> srcJson) =>
_$SettingPageStyleItemModelFromJson(srcJson);

Map<String, dynamic> toJson() => _$SettingPageStyleItemModelToJson(this);
}

+ 28
- 0
lib/pages/setting_page/models/setting_page_style_item_model.g.dart Ver arquivo

@@ -0,0 +1,28 @@
// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'setting_page_style_item_model.dart';

// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************

SettingPageStyleItemModel _$SettingPageStyleItemModelFromJson(
Map<String, dynamic> json) {
return SettingPageStyleItemModel(
json['name'] as String,
json['name_color'] as String,
json['desc'] as String,
json['desc_color'] as String,
json['skip_identifier'] as String,
);
}

Map<String, dynamic> _$SettingPageStyleItemModelToJson(
SettingPageStyleItemModel instance) =>
<String, dynamic>{
'name': instance.name,
'name_color': instance.nameColor,
'desc': instance.desc,
'desc_color': instance.descColor,
'skip_identifier': instance.skipIdentifier,
};

+ 51
- 0
lib/pages/setting_page/models/setting_page_style_model.dart Ver arquivo

@@ -0,0 +1,51 @@
import 'package:zhiying_base_widget/pages/setting_page/models/setting_page_style_item_model.dart';

class SettingPageStyleModel extends Object {
String appBarName;
String appBarNameColor;
String appBarBgColor;
String logoutName;
String logoutNameColor;
String settingsBgColor;
List<List<SettingPageStyleItemModel>> settings;

SettingPageStyleModel(this.appBarName,
this.appBarNameColor,
this.appBarBgColor,
this.logoutName,
this.logoutNameColor,
this.settingsBgColor,
this.settings,);

factory SettingPageStyleModel.fromJson(Map<String, dynamic> json) {
var st = (json['settings'] as List).map((list) {
return (list as List)
?.map((item) =>
SettingPageStyleItemModel.fromJson(
Map<String, dynamic>.from(item)))
?.toList() ??
[];
})?.toList();
return SettingPageStyleModel(
json['app_bar_name'] as String,
json['app_bar_name_color'] as String,
json['app_bar_bg_color'] as String,
json['logout_name'] as String,
json['logout_name_color'] as String,
json['settings_bg_color'] as String,
st,
);
}

Map<String, dynamic> toJson() {
return <String, dynamic>{
'app_bar_name': this.appBarName,
'app_bar_name_color': this.appBarNameColor,
'app_bar_bg_color': this.appBarBgColor,
'logout_name': this.logoutName,
'logout_name_color': this.logoutNameColor,
'settings_bg_color': this.settingsBgColor,
'settings': this.settings,
};
}
}

+ 111
- 1
lib/pages/setting_page/setting_page.dart Ver arquivo

@@ -1,4 +1,10 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/pages/setting_page/models/setting_page_style_item_model.dart';
import 'package:zhiying_base_widget/pages/setting_page/models/setting_page_style_model.dart';
import 'package:zhiying_base_widget/pages/setting_page/setting_page_bloc.dart';
import 'package:zhiying_comm/util/base_bloc.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class SettingPage extends StatefulWidget {
final Map<String, dynamic> data;
@@ -12,6 +18,110 @@ class SettingPage extends StatefulWidget {
class _SettingPageState extends State<SettingPage> {
@override
Widget build(BuildContext context) {
return Scaffold();
return BlocProvider<SettingPageBloc>(
bloc: SettingPageBloc(),
child: _SettingContainer(widget.data),
);
}
}

class _SettingContainer extends StatefulWidget {
final Map<String, dynamic> data;

const _SettingContainer(
this.data, {
Key key,
}) : super(key: key);

@override
_SettingContainerState createState() => _SettingContainerState();
}

class _SettingContainerState extends State<_SettingContainer> {
SettingPageBloc _bloc;

@override
void initState() {
_bloc = BlocProvider.of<SettingPageBloc>(context);
_bloc.loadData(widget.data['skip_identifier']);
super.initState();
}

@override
Widget build(BuildContext context) {
return StreamBuilder<SettingPageStyleModel>(
stream: _bloc.outData,
builder: (BuildContext context, AsyncSnapshot snapshot) {
SettingPageStyleModel style = snapshot.data;
return Scaffold(
backgroundColor: Color(0xfff9f9f9),
appBar: _createNav(style),
body: SingleChildScrollView(
child: Column(
children: style?.settings?.map((list) {
return _createSection(list);
})?.toList() ??
[],
),
));
});
}

// 导航栏
Widget _createNav(SettingPageStyleModel style) {
return CupertinoNavigationBar(
border: Border(
bottom: BorderSide(
width: 0.0, // One physical pixel.
style: BorderStyle.none,
),
),
backgroundColor: HexColor.fromHex(style?.appBarBgColor ?? 'ffffff'),
leading: Navigator.canPop(context)
? GestureDetector(
child: Container(
padding: EdgeInsets.zero,
child: Icon(
Icons.arrow_back_ios,
size: 20,
),
),
onTap: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
},
)
: Container(),
middle: Text(
style?.appBarName ?? '设置',
style: TextStyle(
fontSize: 15,
color: HexColor.fromHex(style?.appBarNameColor ?? '333333'),
),
),
);
}

Widget _createSection(List<SettingPageStyleItemModel> sections) {
return Container(
margin: EdgeInsets.only(top: 8),
child: Column(
children: sections.map((item) {
return _createItem(item);
}).toList(),
),
);
}

Widget _createItem(SettingPageStyleItemModel item) {
return Container(
width: double.infinity,
height: 50,
color: Colors.white,
child: Row(
children: <Widget>[Text(item.name), Text('aaaaa')],
),
);
}
}

+ 36
- 0
lib/pages/setting_page/setting_page_bloc.dart Ver arquivo

@@ -0,0 +1,36 @@
import 'dart:async';
import 'dart:convert' as convert;

import 'package:zhiying_base_widget/pages/setting_page/models/setting_page_style_model.dart';
import 'package:zhiying_comm/util/base_bloc.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class SettingPageBloc extends BlocBase {
SettingPageStyleModel _style;

StreamController<SettingPageStyleModel> _styleController =
StreamController<SettingPageStyleModel>();

Stream<SettingPageStyleModel> get outData => _styleController.stream;

@override
void dispose() {
_styleController.close();
_styleController = null;
}

void loadData(String skipIdentifier) async {
Api api = Api(
'/api/v1/mod/${skipIdentifier.toString()}', method: NetMethod.GET,);
_loadData(await api.onCache());
_loadData(await api.onRequest());
}

void _loadData(dynamic data) {
Map<String, dynamic> json = Map<String, dynamic>.from(data);
String d = json['data'];
Map<String, dynamic> da = Map<String, dynamic>.from(convert.jsonDecode(d));
_style = SettingPageStyleModel.fromJson(da);
_styleController.add(_style);
}
}

+ 1
- 1
lib/widgets/mine/mine_nav/mine_nav.dart Ver arquivo

@@ -96,7 +96,7 @@ class MineNavIcon extends StatelessWidget {
),
onTap: () {
print('页面跳转 ${model.skipIdentifier}');
RouterUtil.route(data, context);
RouterUtil.route(model.toJson(), context);
},
);
}


Carregando…
Cancelar
Salvar