Skip to content

Commit

Permalink
general cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
maxisme committed May 2, 2021
1 parent 4913613 commit c7b8755
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 57 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

https://flutter.dev/docs/get-started/install
```bash
flutter channel master
flutter channel dev
flutter upgrade
```

Expand Down
4 changes: 4 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<array>
<string>_dartobservatory._tcp</string>
</array>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>FLogs would like to save photos from the app to your gallery</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>FLogs would like to access your photo gallery for uploading images to the app</string>
<key>NSCalendarsUsageDescription</key>
<string>We don&apos;t access your calendar</string>
<key>NSContactsUsageDescription</key>
Expand Down
4 changes: 3 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:io';

import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app_badger/flutter_app_badger.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
Expand All @@ -22,7 +23,8 @@ Future<void> main() async {
await loadDotEnv();

if (shouldUseFirebase()) {
initFirebase();
final AuthorizationStatus status = await initFirebase();
L.i(status.toString());
}

final DBProvider db = DBProvider('notifications.db');
Expand Down
19 changes: 11 additions & 8 deletions lib/notifications/notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ class NotificationUI extends StatefulWidget {
this.link,
this.id,
this.read,
this.canExpand,
Key key,
}) : super(key: key) {
message = message ?? '';
image = image ?? '';
link = link ?? '';
read = read ?? false;
canExpand = canExpand ?? false;
}

factory NotificationUI.fromJson(Map<String, dynamic> json) =>
Expand All @@ -44,6 +46,7 @@ class NotificationUI extends StatefulWidget {
String link;
int id;
bool read;
bool canExpand;
bool isExpanded = false;
int index;
void Function(int id) toggleExpand;
Expand Down Expand Up @@ -230,7 +233,7 @@ class NotificationUIState extends State<NotificationUI> {
size: iconSize,
color: MyColour.grey,
))),
if (_canExpand)
if (widget.canExpand)
InkWell(
onTap: () {
setState(() {
Expand Down Expand Up @@ -286,10 +289,12 @@ class NotificationUIState extends State<NotificationUI> {
valueListenable: _timeStr,
builder: (BuildContext context,
String timeStr, Widget child) {
return SelectableText(timeStr,
style: const TextStyle(
color: MyColour.grey,
fontSize: 12));
return Expanded(
child: SelectableText(timeStr,
style: const TextStyle(
color: MyColour.grey,
fontSize: 12)),
);
})
]),

Expand All @@ -315,8 +320,6 @@ class NotificationUIState extends State<NotificationUI> {
super.dispose();
}

bool _canExpand = false;

void _canExpandHandler(BuildContext context) {
bool canExpand = false;
// for title
Expand All @@ -332,7 +335,7 @@ class NotificationUIState extends State<NotificationUI> {
}

if (canExpand) {
_canExpand = true;
widget.canExpand = true;
setState(() {});
}
}
Expand Down
14 changes: 8 additions & 6 deletions lib/notifications/notifis.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_app_badger/flutter_app_badger.dart';
import 'package:notifi/notifications/db_provider.dart';
import 'package:notifi/notifications/notification.dart';
import 'package:notifi/utils/utils.dart';
import 'package:flutter_app_badger/flutter_app_badger.dart';

class Notifications extends ChangeNotifier {
Notifications(this.notifications, this.db, this.tableNotifier,
Expand All @@ -27,11 +27,13 @@ class Notifications extends ChangeNotifier {
}

void scrollToTop() {
tableController.animateTo(
tableController.position.minScrollExtent,
duration: const Duration(milliseconds: 250),
curve: Curves.easeOut,
);
if (tableController.hasClients) {
tableController.animateTo(
0,
duration: const Duration(milliseconds: 250),
curve: Curves.easeOut,
);
}
}

int get unreadCnt {
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class HomeScreen extends StatelessWidget {
color: MyColour.darkGrey, size: 45)),
),
SizedBox(
height: double.infinity,
height: 30,
child: Container(color: MyColour.offGrey, width: 1)),
Expanded(
child: SizedBox(
Expand Down
79 changes: 41 additions & 38 deletions lib/screens/logs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,48 @@ class _LogsScreenState extends State<LogsScreen> {

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
toolbarHeight: 80,
leading: IconButton(
icon: const Icon(
Akaricons.chevronLeft,
color: MyColour.darkGrey,
size: 22,
return FutureBuilder<ListView>(
future: logListView(),
// ignore: always_specify_types
builder: (BuildContext context, AsyncSnapshot f) {
Widget widget = const Center(child: CircularProgressIndicator());
if (f.connectionState != ConnectionState.done || f.data == null) {
widget = const Center(child: CircularProgressIndicator());
} else {
widget = Scrollbar(thickness: 4, child: f.data);
}

return Scaffold(
appBar: AppBar(
toolbarHeight: 80,
leading: IconButton(
icon: const Icon(
Akaricons.chevronLeft,
color: MyColour.darkGrey,
size: 22,
),
onPressed: () {
Navigator.pop(context);
}),
title: Column(children: <Widget>[
// ignore: always_specify_types
DropdownButton(
items: <DropdownMenuItem<LogLevel>>[
_menuItem(LogLevel.DEBUG),
_menuItem(LogLevel.INFO),
_menuItem(LogLevel.WARNING),
_menuItem(LogLevel.ERROR),
],
value: _logLevel,
onChanged: (LogLevel val) {
setState(() {
_logLevel = val;
});
})
]),
),
onPressed: () {
Navigator.pop(context);
}),
title: Column(children: <Widget>[
const Text('Logs'),
// ignore: always_specify_types
DropdownButton(
items: <DropdownMenuItem<LogLevel>>[
_menuItem(LogLevel.DEBUG),
_menuItem(LogLevel.INFO),
_menuItem(LogLevel.WARNING),
_menuItem(LogLevel.ERROR),
],
value: _logLevel,
onChanged: (LogLevel val) {
setState(() {
_logLevel = val;
});
})
]),
),
body: FutureBuilder<ListView>(
future: logListView(),
// ignore: always_specify_types
builder: (BuildContext context, AsyncSnapshot f) {
if (f.connectionState != ConnectionState.done) {
return const Center(child: CircularProgressIndicator());
}
return Scrollbar(thickness: 4, child: f.data);
}));
body: widget);
});
}

Future<ListView> logListView() async {
Expand Down
3 changes: 1 addition & 2 deletions lib/screens/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ class SettingOption extends StatelessWidget {
padding: const EdgeInsets.only(right: 10),
child: Icon(icon, size: 20, color: MyColour.black));

// switch or link
Widget setting;
if (switchCallback == null) {
setting = Container(
Expand All @@ -270,7 +269,7 @@ class SettingOption extends StatelessWidget {
} else {
switchValue ??= false;
setting = Container(
padding: const EdgeInsets.only(left: 23, right: 7, top: 10),
padding: const EdgeInsets.only(left: 15, right: 7, top: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expand Down
Binary file modified test/golden-asserts/screen/no-notifications.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/golden-asserts/screen/notification.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/golden-asserts/screen/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c7b8755

Please sign in to comment.