|
@@ -12,6 +12,15 @@ import 'Services/PackageService.dart';
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
|
|
class PackageView extends StatefulWidget {
|
|
|
+ static List<String> DeviceTypes = ['PC', 'Android', 'Mac'];
|
|
|
+ static List<String> Languages = [
|
|
|
+ 'Chinese',
|
|
|
+ 'English',
|
|
|
+ 'Portuguese',
|
|
|
+ 'Romanian',
|
|
|
+ 'Russian'
|
|
|
+ ];
|
|
|
+ static List<String> LangKeys = ['zh-CN', 'en-US', 'pt-PT', 'ro-RO', 'ru-RU'];
|
|
|
int DeployYear = 0;
|
|
|
@override
|
|
|
_RecordListState createState() => _RecordListState();
|
|
@@ -223,6 +232,25 @@ class _RecordListState extends State<PackageView> {
|
|
|
onPressed: () {
|
|
|
try {
|
|
|
var detail = new DeployRecordInfoDTO(id: '');
|
|
|
+ var upgradeInfos =
|
|
|
+ new List<DeployRecordUpgradeInfoDTO>.empty(growable: true);
|
|
|
+
|
|
|
+ for (var i = 0; i < PackageView.DeviceTypes.length; i++) {
|
|
|
+ for (var j = 0; j < PackageView.LangKeys.length; j++) {
|
|
|
+ var current = detail.upgradeInfos?.firstWhere(
|
|
|
+ (element) =>
|
|
|
+ element.deviceType.index == i &&
|
|
|
+ element.language == PackageView.LangKeys[j],
|
|
|
+ orElse: () => new DeployRecordUpgradeInfoDTO());
|
|
|
+ var text = current?.describe ?? '';
|
|
|
+ upgradeInfos.add(new DeployRecordUpgradeInfoDTO(
|
|
|
+ deviceType: DeployDeviceEnum.values[i],
|
|
|
+ language: PackageView.LangKeys[j],
|
|
|
+ describe: text));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ detail.upgradeInfos = upgradeInfos;
|
|
|
var json = jsonEncode(detail);
|
|
|
Navigator.restorablePush<String>(context, _fullscreenDialogRoute,
|
|
|
arguments: json);
|
|
@@ -272,7 +300,7 @@ class _RecordListState extends State<PackageView> {
|
|
|
var json = arguments as String;
|
|
|
var detail = DeployRecordInfoDTO.fromJson(jsonDecode(json));
|
|
|
return MaterialPageRoute<String>(
|
|
|
- builder: (context) => _FullScreenDialogDemo(detail),
|
|
|
+ builder: (context) => PackageDetailDialog(detail),
|
|
|
fullscreenDialog: true,
|
|
|
);
|
|
|
}
|
|
@@ -285,54 +313,26 @@ class PackageDetailArgs {
|
|
|
const PackageDetailArgs(this.operators, this.detail);
|
|
|
}
|
|
|
|
|
|
-class _FullScreenDialogDemo extends StatelessWidget {
|
|
|
+class PackageDetailDialog extends StatefulWidget {
|
|
|
final DeployRecordInfoDTO detail;
|
|
|
- TextEditingController _version = TextEditingController();
|
|
|
- TextEditingController _internalRecord = TextEditingController();
|
|
|
- List<DeployRecordUpgradeInfoDTO> upgradeInfos = [];
|
|
|
- List<String> deviceTypes = ['PC', 'Android', 'Mac'];
|
|
|
- List<String> languages = [
|
|
|
- 'Chinese',
|
|
|
- 'English',
|
|
|
- 'Portuguese',
|
|
|
- 'Romanian',
|
|
|
- 'Russian'
|
|
|
- ];
|
|
|
- List<String> langKeys = ['zh-CN', 'en-US', 'pt-PT', 'ro-RO', 'ru-RU'];
|
|
|
- List<TextEditingController> _controllers = [];
|
|
|
- _FullScreenDialogDemo(this.detail);
|
|
|
+ PackageDetailDialog(this.detail);
|
|
|
+ @override
|
|
|
+ _PackageDetailDialogState createState() => _PackageDetailDialogState(detail);
|
|
|
+}
|
|
|
+
|
|
|
+class _PackageDetailDialogState extends State<PackageDetailDialog> {
|
|
|
+ final DeployRecordInfoDTO detail;
|
|
|
+
|
|
|
+ _PackageDetailDialogState(this.detail);
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
final theme = Theme.of(context);
|
|
|
final localizations = AppLocalizations.of(context)!;
|
|
|
|
|
|
- _version.text = detail.version ?? '';
|
|
|
-
|
|
|
- _internalRecord.text = detail.internalRecord ?? '';
|
|
|
-
|
|
|
// 初始化下拉菜单项
|
|
|
Iterable<String> operatorItems =
|
|
|
_RecordListState.Operators.map((e) => e.name);
|
|
|
- // String? selectedItem;
|
|
|
|
|
|
- detail.upgradeInfos = detail.upgradeInfos ?? [];
|
|
|
-
|
|
|
- for (var i = 0; i < deviceTypes.length; i++) {
|
|
|
- for (var j = 0; j < langKeys.length; j++) {
|
|
|
- var current = detail.upgradeInfos?.firstWhere(
|
|
|
- (element) =>
|
|
|
- element.deviceType.index == i &&
|
|
|
- element.language == langKeys[j],
|
|
|
- orElse: () => new DeployRecordUpgradeInfoDTO());
|
|
|
- var text = current?.describe ?? '';
|
|
|
- upgradeInfos.add(new DeployRecordUpgradeInfoDTO(
|
|
|
- deviceType: DeployDeviceEnum.values[i],
|
|
|
- language: langKeys[j],
|
|
|
- describe: text));
|
|
|
- _controllers.add(new TextEditingController(text: text));
|
|
|
- }
|
|
|
- }
|
|
|
- detail.upgradeInfos = upgradeInfos;
|
|
|
// Remove the MediaQuery padding because the demo is rendered inside of a
|
|
|
// different page that already accounts for this padding.
|
|
|
return MediaQuery.removePadding(
|
|
@@ -347,7 +347,6 @@ class _FullScreenDialogDemo extends StatelessWidget {
|
|
|
actions: [
|
|
|
TextButton(
|
|
|
onPressed: () {
|
|
|
- detail.upgradeInfos = upgradeInfos;
|
|
|
onSavePressed(detail, context);
|
|
|
},
|
|
|
child: Text(
|
|
@@ -360,9 +359,8 @@ class _FullScreenDialogDemo extends StatelessWidget {
|
|
|
],
|
|
|
),
|
|
|
body: Padding(
|
|
|
- padding: EdgeInsets.all(16.0),
|
|
|
- child: StatefulBuilder(builder: (BuildContext context, setState) {
|
|
|
- return SingleChildScrollView(
|
|
|
+ padding: EdgeInsets.all(16.0),
|
|
|
+ child: SingleChildScrollView(
|
|
|
child: Column(
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
@@ -385,7 +383,8 @@ class _FullScreenDialogDemo extends StatelessWidget {
|
|
|
width: 280,
|
|
|
child: TextField(
|
|
|
textAlignVertical: TextAlignVertical.top,
|
|
|
- controller: _version,
|
|
|
+ controller: TextEditingController(
|
|
|
+ text: detail.version),
|
|
|
decoration: InputDecoration(
|
|
|
contentPadding: EdgeInsets.symmetric(
|
|
|
vertical: 0, horizontal: 10),
|
|
@@ -395,10 +394,7 @@ class _FullScreenDialogDemo extends StatelessWidget {
|
|
|
),
|
|
|
),
|
|
|
onChanged: (String? newValue) {
|
|
|
- // 在这里处理下拉框选项更改事件
|
|
|
- setState(() {
|
|
|
- detail.version = newValue;
|
|
|
- });
|
|
|
+ detail.version = newValue;
|
|
|
},
|
|
|
)),
|
|
|
],
|
|
@@ -446,7 +442,6 @@ class _FullScreenDialogDemo extends StatelessWidget {
|
|
|
},
|
|
|
).toList(),
|
|
|
onChanged: (String? newValue) {
|
|
|
- // 在这里处理下拉框选项更改事件
|
|
|
setState(() {
|
|
|
detail.releasedBy = newValue;
|
|
|
});
|
|
@@ -464,7 +459,8 @@ class _FullScreenDialogDemo extends StatelessWidget {
|
|
|
Text(localizations.internalRecord),
|
|
|
SizedBox(height: 10),
|
|
|
TextField(
|
|
|
- controller: _internalRecord,
|
|
|
+ controller: TextEditingController(
|
|
|
+ text: detail.internalRecord),
|
|
|
decoration: InputDecoration(
|
|
|
border: OutlineInputBorder(
|
|
|
borderRadius: BorderRadius.circular(5.0),
|
|
@@ -473,10 +469,7 @@ class _FullScreenDialogDemo extends StatelessWidget {
|
|
|
maxLines: 8, // 允许多行输入
|
|
|
keyboardType: TextInputType.multiline,
|
|
|
onChanged: (String? newValue) {
|
|
|
- // 在这里处理下拉框选项更改事件
|
|
|
- setState(() {
|
|
|
- detail.internalRecord = newValue;
|
|
|
- });
|
|
|
+ detail.internalRecord = newValue;
|
|
|
},
|
|
|
),
|
|
|
]),
|
|
@@ -484,7 +477,7 @@ class _FullScreenDialogDemo extends StatelessWidget {
|
|
|
Container(
|
|
|
height: 500,
|
|
|
child: GridView.builder(
|
|
|
- itemCount: deviceTypes.length,
|
|
|
+ itemCount: PackageView.DeviceTypes.length,
|
|
|
gridDelegate:
|
|
|
SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
crossAxisCount: 3, // 设置为两列
|
|
@@ -495,12 +488,12 @@ class _FullScreenDialogDemo extends StatelessWidget {
|
|
|
itemBuilder: (BuildContext context, int i) {
|
|
|
return Column(
|
|
|
children: [
|
|
|
- Text(deviceTypes[i]),
|
|
|
+ Text(PackageView.DeviceTypes[i]),
|
|
|
SizedBox(height: 8),
|
|
|
Container(
|
|
|
height: 280,
|
|
|
child: DefaultTabController(
|
|
|
- length: languages.length,
|
|
|
+ length: PackageView.Languages.length,
|
|
|
child: Scaffold(
|
|
|
appBar: PreferredSize(
|
|
|
preferredSize: Size.fromHeight(
|
|
@@ -520,9 +513,14 @@ class _FullScreenDialogDemo extends StatelessWidget {
|
|
|
indicatorColor: Colors.blue,
|
|
|
tabs: [
|
|
|
for (int j = 0;
|
|
|
- j < languages.length;
|
|
|
+ j <
|
|
|
+ PackageView
|
|
|
+ .Languages
|
|
|
+ .length;
|
|
|
j++)
|
|
|
- Tab(text: languages[j]),
|
|
|
+ Tab(
|
|
|
+ text: PackageView
|
|
|
+ .Languages[j]),
|
|
|
],
|
|
|
),
|
|
|
)),
|
|
@@ -546,15 +544,22 @@ class _FullScreenDialogDemo extends StatelessWidget {
|
|
|
child: TabBarView(
|
|
|
children: [
|
|
|
for (int j = 0;
|
|
|
- j < languages.length;
|
|
|
+ j <
|
|
|
+ PackageView
|
|
|
+ .Languages.length;
|
|
|
j++)
|
|
|
Padding(
|
|
|
padding:
|
|
|
EdgeInsets.all(8.0),
|
|
|
child: TextField(
|
|
|
- controller: _controllers[
|
|
|
- i * languages.length +
|
|
|
- j],
|
|
|
+ controller: TextEditingController(
|
|
|
+ text: detail
|
|
|
+ .upgradeInfos![i *
|
|
|
+ PackageView
|
|
|
+ .Languages
|
|
|
+ .length +
|
|
|
+ j]
|
|
|
+ .describe),
|
|
|
decoration:
|
|
|
InputDecoration(
|
|
|
border:
|
|
@@ -570,12 +575,85 @@ class _FullScreenDialogDemo extends StatelessWidget {
|
|
|
keyboardType:
|
|
|
TextInputType
|
|
|
.multiline,
|
|
|
- onChanged: (value) => {
|
|
|
- upgradeInfos[i *
|
|
|
- languages
|
|
|
- .length +
|
|
|
- j]
|
|
|
- .describe = value
|
|
|
+ onChanged: (value) {
|
|
|
+ try {
|
|
|
+ detail
|
|
|
+ .upgradeInfos![i *
|
|
|
+ PackageView
|
|
|
+ .Languages
|
|
|
+ .length +
|
|
|
+ j]
|
|
|
+ .describe = value;
|
|
|
+
|
|
|
+ if (i == 0) {
|
|
|
+ if (j == 0) {
|
|
|
+ //PC Chinese, set same initial value for android and mac
|
|
|
+ for (int index =
|
|
|
+ 1;
|
|
|
+ index <
|
|
|
+ PackageView
|
|
|
+ .DeviceTypes
|
|
|
+ .length;
|
|
|
+ index++) {
|
|
|
+ if (detail
|
|
|
+ .upgradeInfos![index *
|
|
|
+ PackageView
|
|
|
+ .Languages
|
|
|
+ .length]
|
|
|
+ .describe!
|
|
|
+ .isEmpty)
|
|
|
+ setState(
|
|
|
+ () {
|
|
|
+ detail
|
|
|
+ .upgradeInfos![index *
|
|
|
+ PackageView.Languages.length]
|
|
|
+ .describe = value;
|
|
|
+ },
|
|
|
+ );
|
|
|
+ }
|
|
|
+ } else if (j == 1) {
|
|
|
+ //PC Engish, set same initial value for android and mac (all non-chinese)
|
|
|
+ for (int index =
|
|
|
+ 0;
|
|
|
+ index <
|
|
|
+ PackageView
|
|
|
+ .DeviceTypes
|
|
|
+ .length;
|
|
|
+ index++) {
|
|
|
+ for (int colIndex =
|
|
|
+ 1;
|
|
|
+ colIndex <
|
|
|
+ PackageView
|
|
|
+ .Languages
|
|
|
+ .length;
|
|
|
+ colIndex++) {
|
|
|
+ if (index ==
|
|
|
+ 0 &&
|
|
|
+ colIndex ==
|
|
|
+ 1)
|
|
|
+ continue;
|
|
|
+ if (detail
|
|
|
+ .upgradeInfos![index *
|
|
|
+ PackageView.Languages.length +
|
|
|
+ colIndex]
|
|
|
+ .describe!
|
|
|
+ .isEmpty)
|
|
|
+ setState(
|
|
|
+ () {
|
|
|
+ detail
|
|
|
+ .upgradeInfos![index * PackageView.Languages.length +
|
|
|
+ colIndex]
|
|
|
+ .describe = value;
|
|
|
+ },
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (ex) {
|
|
|
+ Logger.error(
|
|
|
+ 'Change note ex${ex}');
|
|
|
+ }
|
|
|
},
|
|
|
),
|
|
|
),
|
|
@@ -590,9 +668,7 @@ class _FullScreenDialogDemo extends StatelessWidget {
|
|
|
),
|
|
|
],
|
|
|
),
|
|
|
- );
|
|
|
- }),
|
|
|
- )));
|
|
|
+ ))));
|
|
|
}
|
|
|
|
|
|
void onSavePressed(DeployRecordInfoDTO detail, BuildContext context) async {
|