Skip to content

Commit

Permalink
pull from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanBruh committed Jun 25, 2021
2 parents 8a9737c + ec087d4 commit 1b53fca
Show file tree
Hide file tree
Showing 17 changed files with 324 additions and 384 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ class AccountModel extends HiveObject {
Uint8List? avatarBytes;

@HiveField(5)
bool? isActive = false;
bool? isActive;

AccountModel({
this.login,
this.token,
this.id,
this.clientId,
this.avatarBytes,
this.isActive = false,
});
}
File renamed without changes.
56 changes: 56 additions & 0 deletions lib/Accounts/AccountsCubit.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hive/hive.dart';

import 'AccountModel.dart';

class AccountsCubit extends Cubit<List<AccountModel>> {
Box accountBox;

static AccountModel defaultAccount = AccountModel(
id: 0,
clientId: 'kimne78kx3ncx6brgo4mv6wki5h1ko',
login: 'justinfan64537',
);

AccountsCubit(this.accountBox) : super([]) {
refresh();
}

Future<void> refresh() async {
try {
for (var account in accountBox.values) {
if (account.token == null) {
await (account as HiveObject).delete();
}
}
// ignore: empty_catches
} catch (e) {}
emit([
for (var account in accountBox.values) account as AccountModel,
]);
}

Future<void> add(AccountModel account) async {
await accountBox.add(account);
emit([...state, account]);
}

Future<void> remove(AccountModel account) async {
await account.delete();
emit([...state]..remove(account));
}

Future<AccountModel> getActive() async {
return state.firstWhere((account) => account.isActive ?? false, orElse: () => defaultAccount);
}

Future<void> setActive(AccountModel activeAccount) async {
for (var account in state) {
account.isActive = false;
await account.save();
}
activeAccount.isActive = true;
await activeAccount.save();
emit([...state]);
}
}
2 changes: 1 addition & 1 deletion lib/Badges/SevenTVBadges.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SevenTVBadges extends Cubit<Map<String, List<twitch.Badge>>> {
description: null,
id: badgeData['id'],
mipmap: [
for (var url in badgeData['urls'].take(1)) url.last,
for (var url in badgeData['urls']) url.last,
],
name: badgeData['id'],
tag: badgeData['id'],
Expand Down
32 changes: 16 additions & 16 deletions lib/Components/ChatInputBox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,22 @@ class _ChatInputBoxState extends State<ChatInputBox> {
},
),
),
AspectRatio(
aspectRatio: 1.0,
child: Container(
height: 32.0,
child: InkWell(
onTap: () async => await UploadModal.show(
context,
channel: widget.channel!,
),
child: Icon(
Icons.file_present,
color: Theme.of(context).colorScheme.onSurface.withAlpha(64 * 3),
),
),
),
),
// AspectRatio(
// aspectRatio: 1.0,
// child: Container(
// height: 32.0,
// child: InkWell(
// onTap: () async => await UploadModal.show(
// context,
// channel: widget.channel!,
// ),
// child: Icon(
// Icons.file_present,
// color: Theme.of(context).colorScheme.onSurface.withAlpha(64 * 3),
// ),
// ),
// ),
// ),
AspectRatio(
aspectRatio: 1.0,
child: Container(
Expand Down
3 changes: 1 addition & 2 deletions lib/Components/HomeDrawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '/Components/UI/WidgetBlur.dart';
import '/Pages/Account.dart';
import '/Pages/Profile.dart';
import '/Pages/Search.dart';
import '/Pages/Whispers.dart';
import '/StreamOverlay/StreamOverlayBloc.dart';
Expand Down Expand Up @@ -87,7 +86,7 @@ class HomeDrawer extends StatelessWidget {
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) => AccountPage(
client: client,
client: client!,
),
),
),
Expand Down
50 changes: 0 additions & 50 deletions lib/MVP/Presenters/AccountPresenter.dart

This file was deleted.

112 changes: 0 additions & 112 deletions lib/MVP/Views/AccountView.dart

This file was deleted.

Loading

0 comments on commit 1b53fca

Please sign in to comment.