]> git.proxmox.com Git - flutter/proxmox_login_manager.git/commitdiff
colors and stuff
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 14 Dec 2021 20:32:58 +0000 (21:32 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 14 Dec 2021 20:32:58 +0000 (21:32 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
lib/proxmox_login_form.dart
lib/proxmox_login_selector.dart
pubspec.lock

index 59a9f613d23ae087866a2d18f51a787cc62dbc12..2609f71fd25144e9306f0af36ecf19fe5245e7d7 100644 (file)
@@ -2,6 +2,7 @@ import 'dart:io';
 import 'dart:async';
 
 import 'package:flutter/material.dart';
+import 'package:collection/src/iterable_extensions.dart';
 import 'package:proxmox_dart_api_client/proxmox_dart_api_client.dart'
     as proxclient;
 import 'package:proxmox_dart_api_client/proxmox_dart_api_client.dart';
@@ -20,6 +21,13 @@ class ProxmoxProgressModel {
   });
 }
 
+// FIXME: copied from pve_flutter_frontend, re-use common set
+class ProxmoxColors {
+  static final Color orange = Color(0xFFE57000);
+  static final Color supportGrey = Color(0xFFABBABA);
+  static final Color supportBlue = Color(0xFF00617F);
+}
+
 class ProxmoxLoginForm extends StatefulWidget {
   final TextEditingController originController;
   final FormFieldValidator<String> originValidator;
@@ -33,13 +41,13 @@ class ProxmoxLoginForm extends StatefulWidget {
 
   const ProxmoxLoginForm({
     Key? key,
-    /*required*/ required this.originController,
-    /*required*/ /*required*/ required this.usernameController,
-    /*required*/ required this.passwordController,
-    /*required*/ required this.accessDomains,
-    /*required*/ required this.originValidator,
+    required this.originController,
+    required this.usernameController,
+    required this.passwordController,
+    required this.accessDomains,
+    required this.originValidator,
     this.selectedDomain,
-    /*required*/ required this.onDomainChanged,
+    required this.onDomainChanged,
     this.onPasswordSubmitted,
     this.onOriginSubmitted,
   }) : super(key: key);
@@ -98,7 +106,7 @@ class _ProxmoxLoginFormState extends State<ProxmoxLoginForm> {
             items: widget.accessDomains!
                 .map((e) => DropdownMenuItem(
                       child: ListTile(
-                        title: Text(e!.realm!),
+                        title: Text(e!.realm),
                         subtitle: Text(e.comment ?? ''),
                       ),
                       value: e,
@@ -106,7 +114,7 @@ class _ProxmoxLoginFormState extends State<ProxmoxLoginForm> {
                 .toList(),
             onChanged: widget.onDomainChanged,
             selectedItemBuilder: (context) =>
-                widget.accessDomains!.map((e) => Text(e!.realm!)).toList(),
+                widget.accessDomains!.map((e) => Text(e!.realm)).toList(),
             value: widget.selectedDomain,
           ),
           Stack(
@@ -202,9 +210,13 @@ class _ProxmoxLoginPageState extends State<ProxmoxLoginPage> {
   @override
   Widget build(BuildContext context) {
     return Theme(
-      data: ThemeData.dark().copyWith(accentColor: Color(0xFFE47225)),
+      //data: ThemeData.dark().copyWith(accentColor: Color(0xFFE47225)),
+      data: ThemeData.dark().copyWith(
+          colorScheme: ColorScheme.dark().copyWith(
+              secondary: ProxmoxColors.orange,
+              onSecondary: ProxmoxColors.supportGrey)),
       child: Scaffold(
-        backgroundColor: Theme.of(context).primaryColor,
+        backgroundColor: ProxmoxColors.supportBlue,
         extendBodyBehindAppBar: true,
         appBar: AppBar(
           elevation: 0.0,
@@ -324,7 +336,7 @@ class _ProxmoxLoginPageState extends State<ProxmoxLoginPage> {
                                                 }
                                               }
                                             : null,
-                                        color: Color(0xFFE47225),
+                                        color: ProxmoxColors.orange,
                                         disabledColor: Colors.grey,
                                         child: Text('Continue'),
                                       ),
@@ -355,7 +367,7 @@ class _ProxmoxLoginPageState extends State<ProxmoxLoginPage> {
                                                 }
                                               }
                                             : null,
-                                        color: Color(0xFFE47225),
+                                        color: ProxmoxColors.orange,
                                         child: Text('Continue'),
                                         disabledColor: Colors.grey,
                                       ),
@@ -408,7 +420,7 @@ class _ProxmoxLoginPageState extends State<ProxmoxLoginPage> {
 
       final status = await client.getClusterStatus();
       final hostname =
-          status.singleWhere((element) => element!.local ?? false)!.name;
+          status.singleWhereOrNull((element) => element.local ?? false)?.name;
       var loginStorage = await ProxmoxLoginStorage.fromLocalStorage();
 
       if (widget.isCreate!) {
@@ -525,7 +537,7 @@ class _ProxmoxLoginPageState extends State<ProxmoxLoginPage> {
       }
     }
 
-    response?.sort((a, b) => a!.realm!.compareTo(b!.realm!));
+    response?.sort((a, b) => a!.realm.compareTo(b!.realm));
 
     final selection = response?.singleWhere(
       (e) => e!.realm == widget.userModel?.realm,
index 52655231b0fa813e3ddceade733eb033a3ed6511..2ad51ae8eead50ff8348d0eec8d29a356bd1b32a 100644 (file)
@@ -30,6 +30,7 @@ class _ProxmoxLoginSelectorState extends State<ProxmoxLoginSelector> {
   Widget build(BuildContext context) {
     return SafeArea(
       child: Scaffold(
+        backgroundColor: Theme.of(context).colorScheme.background,
         appBar: AppBar(
           title: Column(
             crossAxisAlignment: CrossAxisAlignment.start,
index 9c7c23b506e82c435efb63754f421999cc4d946b..33a3dd5a7f46715fdff8556c922f475ef6cd97f6 100644 (file)
@@ -407,7 +407,7 @@ packages:
       name: shared_preferences
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.0.9"
+    version: "2.0.10"
   shared_preferences_android:
     dependency: transitive
     description: