Improve adherence to material design guidelines

This commit is contained in:
Nutcake 2023-09-29 16:24:26 +02:00
parent b1f2d65ab8
commit e3837066bb
9 changed files with 59 additions and 52 deletions

View file

@ -14,6 +14,7 @@ import 'package:contacts_plus_plus/widgets/update_notifier.dart';
import 'package:dynamic_color/dynamic_color.dart'; import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_downloader/flutter_downloader.dart'; import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:flutter_phoenix/flutter_phoenix.dart'; import 'package:flutter_phoenix/flutter_phoenix.dart';
import 'package:hive_flutter/hive_flutter.dart'; import 'package:hive_flutter/hive_flutter.dart';
@ -132,12 +133,14 @@ class _ContactsPlusPlusState extends State<ContactsPlusPlus> {
theme: ThemeData( theme: ThemeData(
useMaterial3: true, useMaterial3: true,
textTheme: _typography.black, textTheme: _typography.black,
canvasColor: lightDynamic?.surfaceVariant,
colorScheme: colorScheme:
lightDynamic ?? ColorScheme.fromSeed(seedColor: Colors.purple, brightness: Brightness.light), lightDynamic ?? ColorScheme.fromSeed(seedColor: Colors.purple, brightness: Brightness.light),
), ),
darkTheme: ThemeData( darkTheme: ThemeData(
useMaterial3: true, useMaterial3: true,
textTheme: _typography.white, textTheme: _typography.white,
canvasColor: darkDynamic?.surfaceVariant,
colorScheme: darkDynamic ?? ColorScheme.fromSeed(seedColor: Colors.purple, brightness: Brightness.dark), colorScheme: darkDynamic ?? ColorScheme.fromSeed(seedColor: Colors.purple, brightness: Brightness.dark),
), ),
themeMode: ThemeMode.values[widget.settingsClient.currentSettings.themeMode.valueOrDefault], themeMode: ThemeMode.values[widget.settingsClient.currentSettings.themeMode.valueOrDefault],

View file

@ -20,7 +20,7 @@ class Friend implements Comparable {
required this.contactStatus, required this.latestMessageTime, required this.contactStatus, required this.latestMessageTime,
}); });
bool get isHeadless => userStatus.activeSessions.any((session) => session.headlessHost == true && session.hostUserId == id); bool get isHeadless => userStatus.outputDevice == "Headless";
factory Friend.fromMap(Map map) { factory Friend.fromMap(Map map) {
var userStatus = map["userStatus"] == null ? UserStatus.empty() : UserStatus.fromMap(map["userStatus"]); var userStatus = map["userStatus"] == null ? UserStatus.empty() : UserStatus.fromMap(map["userStatus"]);

View file

@ -6,6 +6,7 @@ import 'package:contacts_plus_plus/models/users/user_status.dart';
import 'package:contacts_plus_plus/widgets/friends/user_search.dart'; import 'package:contacts_plus_plus/widgets/friends/user_search.dart';
import 'package:contacts_plus_plus/widgets/my_profile_dialog.dart'; import 'package:contacts_plus_plus/widgets/my_profile_dialog.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -49,6 +50,9 @@ class _FriendsListAppBarState extends State<FriendsListAppBar> with AutomaticKee
super.build(context); super.build(context);
return AppBar( return AppBar(
title: const Text("Contacts++"), title: const Text("Contacts++"),
systemOverlayStyle: SystemUiOverlayStyle(
systemNavigationBarColor: Theme.of(context).colorScheme.surfaceVariant,
),
actions: [ actions: [
FutureBuilder( FutureBuilder(
future: _userStatusFuture, future: _userStatusFuture,

View file

@ -29,6 +29,7 @@ class _HomeState extends State<Home> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: Theme.of(context).colorScheme.surface,
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: const Size.fromHeight(kToolbarHeight), preferredSize: const Size.fromHeight(kToolbarHeight),
child: AnimatedSwitcher( child: AnimatedSwitcher(
@ -46,46 +47,40 @@ class _HomeState extends State<Home> {
SettingsPage(), SettingsPage(),
], ],
), ),
bottomNavigationBar: Container( bottomNavigationBar: BottomNavigationBar(
decoration: BoxDecoration( backgroundColor: Theme.of(context).colorScheme.surfaceVariant,
border: const Border(top: BorderSide(width: 1, color: Colors.black)), type: BottomNavigationBarType.fixed,
color: Theme.of(context).colorScheme.background, unselectedItemColor: Theme.of(context).colorScheme.onBackground,
), selectedItemColor: Theme.of(context).colorScheme.primary,
child: BottomNavigationBar( currentIndex: _selectedPage,
backgroundColor: Theme.of(context).colorScheme.surface, onTap: (index) {
type: BottomNavigationBarType.fixed, _pageController.animateToPage(
unselectedItemColor: Theme.of(context).colorScheme.onBackground, index,
selectedItemColor: Theme.of(context).colorScheme.primary, duration: const Duration(milliseconds: 200),
currentIndex: _selectedPage, curve: Curves.easeOut,
onTap: (index) { );
_pageController.animateToPage( setState(() {
index, _selectedPage = index;
duration: const Duration(milliseconds: 200), });
curve: Curves.easeOut, },
); items: const [
setState(() { BottomNavigationBarItem(
_selectedPage = index; icon: Icon(Icons.message),
}); label: "Chat",
}, ),
items: const [ BottomNavigationBarItem(
BottomNavigationBarItem( icon: Icon(Icons.public),
icon: Icon(Icons.message), label: "Sessions",
label: "Chat", ),
), BottomNavigationBarItem(
BottomNavigationBarItem( icon: Icon(Icons.inventory),
icon: Icon(Icons.public), label: "Inventory",
label: "Sessions", ),
), BottomNavigationBarItem(
BottomNavigationBarItem( icon: Icon(Icons.settings),
icon: Icon(Icons.inventory), label: "Settings",
label: "Inventory", ),
), ],
BottomNavigationBarItem(
icon: Icon(Icons.settings),
label: "Settings",
),
],
),
), ),
); );
} }

View file

@ -5,6 +5,7 @@ import 'package:contacts_plus_plus/auxiliary.dart';
import 'package:contacts_plus_plus/clients/inventory_client.dart'; import 'package:contacts_plus_plus/clients/inventory_client.dart';
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_downloader/flutter_downloader.dart'; import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:path/path.dart'; import 'package:path/path.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -60,10 +61,16 @@ class _InventoryBrowserAppBarState extends State<InventoryBrowserAppBar> {
? AppBar( ? AppBar(
key: const ValueKey("default-appbar"), key: const ValueKey("default-appbar"),
title: const Text("Inventory"), title: const Text("Inventory"),
systemOverlayStyle: SystemUiOverlayStyle(
systemNavigationBarColor: Theme.of(context).colorScheme.surfaceVariant,
),
) )
: AppBar( : AppBar(
key: const ValueKey("selection-appbar"), key: const ValueKey("selection-appbar"),
title: Text("${iClient.selectedRecordCount} Selected"), title: Text("${iClient.selectedRecordCount} Selected"),
systemOverlayStyle: SystemUiOverlayStyle(
systemNavigationBarColor: Theme.of(context).colorScheme.surfaceVariant,
),
leading: IconButton( leading: IconButton(
onPressed: () { onPressed: () {
iClient.clearSelectedRecords(); iClient.clearSelectedRecords();

View file

@ -3,6 +3,7 @@ import 'package:contacts_plus_plus/clients/session_client.dart';
import 'package:contacts_plus_plus/clients/settings_client.dart'; import 'package:contacts_plus_plus/clients/settings_client.dart';
import 'package:contacts_plus_plus/widgets/sessions/session_filter_dialog.dart'; import 'package:contacts_plus_plus/widgets/sessions/session_filter_dialog.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class SessionListAppBar extends StatefulWidget { class SessionListAppBar extends StatefulWidget {
@ -17,6 +18,9 @@ class _SessionListAppBarState extends State<SessionListAppBar> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppBar( return AppBar(
title: const Text("Sessions"), title: const Text("Sessions"),
systemOverlayStyle: SystemUiOverlayStyle(
systemNavigationBarColor: Theme.of(context).colorScheme.surfaceVariant,
),
actions: [ actions: [
Padding( Padding(
padding: const EdgeInsets.only(right: 4.0), padding: const EdgeInsets.only(right: 4.0),

View file

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class SettingsAppBar extends StatelessWidget { class SettingsAppBar extends StatelessWidget {
const SettingsAppBar({super.key}); const SettingsAppBar({super.key});
@ -7,7 +8,9 @@ class SettingsAppBar extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppBar( return AppBar(
title: const Text("Settings"), title: const Text("Settings"),
systemOverlayStyle: SystemUiOverlayStyle(
systemNavigationBarColor: Theme.of(context).colorScheme.surfaceVariant,
),
); );
} }
}
}

View file

@ -153,14 +153,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.17.2" version: "0.17.2"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be
url: "https://pub.dev"
source: hosted
version: "1.0.5"
dbus: dbus:
dependency: transitive dependency: transitive
description: description:

View file

@ -31,7 +31,6 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
cupertino_icons: ^1.0.2
http: ^0.13.5 http: ^0.13.5
http_parser: ^4.0.2 http_parser: ^4.0.2
uuid: ^3.0.7 uuid: ^3.0.7