Browse Source

add default values for different platform when filled the PC note

arthur.wu 1 year ago
parent
commit
6505f4a97a

+ 1 - 34
Tools/Flyinsono.Deployment/lib/AutoTestView.dart

@@ -31,40 +31,7 @@ class _AutoTestView extends State<AutoTestView> {
     GlobalKey<AutoCompleteTextFieldState<String>> typeKey = GlobalKey();
     GlobalKey listKey = GlobalKey();
     return Scaffold(
-      body: Center(
-        child: Column(
-          children: [
-            Row(
-              children: [],
-            ),
-            Padding(
-                padding: const EdgeInsets.all(8.0),
-                child: DropdownButtonFormField<String>(
-                  key: typeKey,
-                  value: selectedType,
-                  decoration: InputDecoration(hintText: "Select one state"),
-                  items: items
-                      .map((e) => DropdownMenuItem<String>(
-                            child: Text(e),
-                            value: e,
-                          ))
-                      .toList(),
-                  onChanged: (value) {
-                    selectedType = value;
-                  },
-                )),
-            Row(
-              children: [
-                TextButton.icon(
-                    onPressed: () => setState(() {}),
-                    icon: Icon(Icons.search),
-                    label: Text("Search")),
-              ],
-            ),
-            Expanded(child: Center()),
-          ],
-        ),
-      ),
+      body: Center(child: Text("TODO")),
     );
   }
 }

+ 11 - 0
Tools/Flyinsono.Deployment/lib/BuildHistoryList.dart

@@ -1,5 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:get_it/get_it.dart';
+import 'package:ustest/Services/BuildTargetPlatform.dart';
 import 'package:ustest/tool.dart';
 import 'Services/BuildService.dart';
 
@@ -46,6 +47,15 @@ class _BuildHistoryListState extends State<BuildHistoryList> {
             ),
           ),
         ),
+        DataColumn(
+          label: Expanded(
+            child: Text(
+              'Platform',
+              style: TextStyle(
+                  fontStyle: FontStyle.italic, fontWeight: FontWeight.bold),
+            ),
+          ),
+        ),
         DataColumn(
           label: Expanded(
             child: Text(
@@ -80,6 +90,7 @@ class _BuildHistoryListState extends State<BuildHistoryList> {
             cells: <DataCell>[
               DataCell(Text(widget.histories[index].id)),
               DataCell(Text(widget.histories[index].status.text)),
+              DataCell(Text(widget.histories[index].platform.text)),
               DataCell(Text(widget.histories[index].startTime.toString())),
               DataCell(Text(widget.histories[index].endTime.toString())),
               DataCell(Row(

+ 24 - 19
Tools/Flyinsono.Deployment/lib/BuildView.dart

@@ -21,17 +21,18 @@ class _BuildView extends State<BuildView> {
     BuildTargetPlatform.Linux,
     BuildTargetPlatform.IOS
   ];
+
   BuildTargetPlatform? selectedPlatform = BuildTargetPlatform.Windows;
   GlobalKey<AutoCompleteTextFieldState<String>> platformKey =
       GlobalKey<AutoCompleteTextFieldState<String>>();
   @override
   Widget build(BuildContext context) {
     Future<List<BuildHistory>> future = fetchBuildHistories();
-
     GlobalKey listKey = GlobalKey();
     return Scaffold(
       body: Center(
         child: Column(
+          crossAxisAlignment: CrossAxisAlignment.start,
           children: [
             Row(
               children: [
@@ -80,26 +81,29 @@ class _BuildView extends State<BuildView> {
                 )
               ],
             ),
-            const SizedBox(width: 7),
-            Expanded(
-              child: FutureBuilder<List<BuildHistory>>(
-                key: listKey,
-                future: future,
-                builder: (context, snapshot) {
-                  if (snapshot.hasError) {
-                    return const Center(
-                      child: Text('An error has occurred!'),
-                    );
-                  } else if (snapshot.hasData) {
-                    return BuildHistoryList(
-                        token: "accessToken", histories: snapshot.data!);
-                  } else {
+            const SizedBox(width: 16),
+            FutureBuilder<List<BuildHistory>>(
+              key: listKey,
+              future: future,
+              builder: (context, snapshot) {
+                if (snapshot.hasError) {
+                  return const Center(
+                    child: Text('An error has occurred!'),
+                  );
+                } else if (snapshot.hasData) {
+                  if (snapshot.data!.length <= 0) {
                     return const Center(
-                      child: CircularProgressIndicator(),
+                      child: Text('TODO!'),
                     );
                   }
-                },
-              ),
+                  return BuildHistoryList(
+                      token: "accessToken", histories: snapshot.data!);
+                } else {
+                  return const Center(
+                    child: CircularProgressIndicator(),
+                  );
+                }
+              },
             ),
           ],
         ),
@@ -121,7 +125,8 @@ class _BuildView extends State<BuildView> {
   void onBuild(context) {
     try {
       var service = GetIt.instance.get<BuildService>();
-      var result = service.Run(BuildTargetPlatform.Linux);
+      var result = service.Run(selectedPlatform);
+      setState(() {});
     } catch (ex) {
       Logger.error("onBuild ex:${ex}");
     }

+ 8 - 7
Tools/Flyinsono.Deployment/lib/Controls/ProgressButton.dart

@@ -59,17 +59,18 @@ class _ProgressButtonState extends State<ProgressButton> {
                         foregroundColor: Colors.white,
                         backgroundColor: Colors.green),
                     onPressed: () {
-                      setState(() {
-                        isLoading = true;
-                      });
+                      try {
+                        setState(() {
+                          isLoading = true;
+                        });
 
-                      // we had used future delayed to stop loading after
-                      // 3 seconds and show text "submit" on the screen.
-                      Future.delayed(const Duration(seconds: 3), () {
+                        onPressed();
+                      } catch (ex) {
+                      } finally {
                         setState(() {
                           isLoading = false;
                         });
-                      });
+                      }
                     },
                     child: isLoading
                         ? Row(

+ 148 - 72
Tools/Flyinsono.Deployment/lib/PackageView.dart

@@ -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 {

+ 2 - 2
Tools/Flyinsono.Deployment/lib/Services/BuildService.dart

@@ -31,14 +31,14 @@ class BuildService {
     return list;
   }
 
-  Run(BuildTargetPlatform platform) {
+  void Run(BuildTargetPlatform? platform) {
     DateTime myDateTime = DateTime.now();
     String formattedDateTime = DateFormat('yyyyMMddHHmmss').format(myDateTime);
     list.add(new BuildHistory(
         id: "id_" + formattedDateTime,
         userName: '',
         status: BuildStatus.Building,
-        platform: platform,
+        platform: platform!,
         startTime: DateTime.now(),
         endTime: DateTime.now()));
   }

+ 12 - 4
Tools/Flyinsono.Deployment/pubspec.lock

@@ -145,6 +145,14 @@ packages:
       url: "https://pub.flutter-io.cn"
     source: hosted
     version: "6.1.4"
+  file_picker:
+    dependency: "direct main"
+    description:
+      name: file_picker
+      sha256: e6c7ad8e572379df86ea64ef0a5395889fba3954411d47ca021b888d79f8e798
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "5.2.11"
   fis_common:
     dependency: transitive
     description:
@@ -419,10 +427,10 @@ packages:
     dependency: transitive
     description:
       name: path_provider_windows
-      sha256: f53720498d5a543f9607db4b0e997c4b5438884de25b0f73098cc2671a51b130
+      sha256: d3f80b32e83ec208ac95253e0cd4d298e104fbc63cb29c5c69edaed43b0c69d6
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "2.1.5"
+    version: "2.1.6"
   platform:
     dependency: transitive
     description:
@@ -608,10 +616,10 @@ packages:
     dependency: transitive
     description:
       name: win32
-      sha256: a6f0236dbda0f63aa9a25ad1ff9a9d8a4eaaa5012da0dc59d21afdb1dc361ca4
+      sha256: dd8f9344bc305ae2923e3d11a2a911d9a4e2c7dd6fe0ed10626d63211a69676e
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "3.1.4"
+    version: "4.1.3"
   xdg_directories:
     dependency: transitive
     description: