feat: More resturcturings, adapt code to previous changes

This commit is contained in:
Anton Stubenbord
2023-05-01 23:05:54 +02:00
parent 88085b5662
commit d5c68e023c
35 changed files with 475 additions and 200 deletions

View File

@@ -86,11 +86,11 @@ class ManageAccountsPage extends StatelessWidget {
final child = SizedBox(
width: double.maxFinite,
child: ListTile(
title: Text(account.username),
title: Text(account.paperlessUser.username),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (account.fullName != null) Text(account.fullName!),
if (account.paperlessUser.fullName != null) Text(account.paperlessUser.fullName!),
Text(
account.serverUrl.replaceFirst(RegExp(r'https://?'), ''),
style: TextStyle(
@@ -99,7 +99,7 @@ class ManageAccountsPage extends StatelessWidget {
),
],
),
isThreeLine: account.fullName != null,
isThreeLine: account.paperlessUser.fullName != null,
leading: UserAvatar(
account: account,
userId: userId,

View File

@@ -22,7 +22,7 @@ class SettingsPage extends StatelessWidget {
final host = user!.serverUrl.replaceFirst(RegExp(r"https?://"), "");
return ListTile(
title: Text(
S.of(context)!.loggedInAs(user.username) + "@$host",
S.of(context)!.loggedInAs(user.paperlessUser.username) + "@$host",
style: Theme.of(context).textTheme.labelSmall,
textAlign: TextAlign.center,
),

View File

@@ -1,5 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/database/tables/local_user_account.dart';
import 'package:paperless_mobile/core/repository/user_repository.dart';
class UserAvatar extends StatelessWidget {
final String userId;
@@ -16,7 +19,7 @@ class UserAvatar extends StatelessWidget {
final backgroundColor = Colors.primaries[userId.hashCode % Colors.primaries.length];
final foregroundColor = backgroundColor.computeLuminance() > 0.5 ? Colors.black : Colors.white;
return CircleAvatar(
child: Text((account.fullName ?? account.username)
child: Text((account.paperlessUser.fullName ?? account.paperlessUser.username)
.split(" ")
.take(2)
.map((e) => e.substring(0, 1))