Skip to content

Commit

Permalink
moved some files around
Browse files Browse the repository at this point in the history
fixed the current plague star bug
  • Loading branch information
Ludwig committed Sep 21, 2018
1 parent 7d8e2f2 commit a746b31
Show file tree
Hide file tree
Showing 51 changed files with 340 additions and 281 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build/
.flutter-plugins
.idea
assets/svg/
lib/util/keys.dart
lib/resources/keys.dart
lib/resources/notifications.dart
android/key.properties
android/app/google-services.json
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-rc02'
classpath 'com.android.tools.build:gradle:3.2.0-rc03'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.0.1'
}
Expand Down
4 changes: 2 additions & 2 deletions lib/app.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';

import 'model.dart';
import 'screens/home.dart';
import 'app_model.dart';
import 'ui/screens/home.dart';

class Navis extends StatelessWidget {
final NavisModel model;
Expand Down
65 changes: 37 additions & 28 deletions lib/model.dart → lib/app_model.dart
Original file line number Diff line number Diff line change
@@ -1,52 +1,54 @@
import 'dart:async';

import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:scoped_model/scoped_model.dart';

import 'animation/countdown.dart';
import 'json/export.dart';
import 'services/state.dart';
import 'models/export.dart';
import 'network/state.dart';
import 'resources/notifications.dart';
import 'ui/animation/countdown.dart';

class NavisModel extends Model {
final SystemState state;
final SystemState state = SystemState();
final Notifications notification = Notifications();
final fcm = FirebaseMessaging();
final DateFormat _format = DateFormat.jms().add_yMd();

bool _isLoading = false;
bool _hasError = false;
WorldState _worldState;

NavisModel({this.state});
WorldState worldState;

bool get isLoading => _isLoading;

bool get hasError => _hasError;

Cetus get cetus => _worldState.cetus;
Cetus get cetus => worldState.cetus;

Earth get earth => _worldState.earth;
Earth get earth => worldState.earth;

Sortie get sortie => _worldState.sortie;
Sortie get sortie => worldState.sortie;

VoidTrader get trader => _worldState.trader;
VoidTrader get trader => worldState.trader;

List<Alerts> get alerts => _worldState.alerts;
List<Alerts> get alerts => worldState.alerts;

List<Events> get events => _worldState.events;
List<Events> get events => worldState.events;

List<VoidFissures> get fissures => _worldState.voidFissures;
List<VoidFissures> get fissures => worldState.voidFissures;

List<OrbiterNews> get news => _worldState.news;
List<OrbiterNews> get news => worldState.news;

List<PersistentEnemies> get enemies => _worldState.persistentEnemies;
List<PersistentEnemies> get enemies => worldState.persistentEnemies;

List<Syndicates> get syndicates => _worldState.syndicates;
List<Syndicates> get syndicates => worldState.syndicates;

List<Invasions> get invasion => _worldState.invasions;
List<Invasions> get invasion => worldState.invasions;

Stream<Duration> get cetusTime {
String expiry = _worldState.cetus.expiry;
bool isDay = _worldState.cetus.isDay;
String expiry = worldState.cetus.expiry;
bool isDay = worldState.cetus.isDay;
Duration time;

try {
Expand All @@ -69,17 +71,17 @@ class NavisModel extends Model {
}

Stream<Duration> get earthTime => CounterScreenStream(
DateTime.parse(_worldState.earth.expiry).difference(DateTime.now()));
DateTime.parse(worldState.earth.expiry).difference(DateTime.now()));

String get cetusExpiry {
String expiry;
Duration day = Duration(minutes: 100);
Duration night = Duration(minutes: 50);

try {
expiry = _format.format(DateTime.parse(_worldState.cetus.expiry));
expiry = _format.format(DateTime.parse(worldState.cetus.expiry));
} catch (err) {
if (_worldState.cetus.isDay)
if (worldState.cetus.isDay)
expiry = _format.format(DateTime.now().add(day));
else
expiry = _format.format(DateTime.now().add(night));
Expand All @@ -94,9 +96,9 @@ class NavisModel extends Model {

try {
expiry =
_format.format(DateTime.parse(_worldState.earth.expiry).toLocal());
_format.format(DateTime.parse(worldState.earth.expiry).toLocal());
} catch (err) {
if (_worldState.earth.isDay)
if (worldState.earth.isDay)
expiry = _format.format(DateTime.now().add(cycle));
else
expiry = _format.format(DateTime.now().add(cycle));
Expand All @@ -106,17 +108,17 @@ class NavisModel extends Model {
}

String get arrival =>
_format.format(DateTime.parse(_worldState.trader.activation).toLocal());
_format.format(DateTime.parse(worldState.trader.activation).toLocal());

String get departure =>
_format.format(DateTime.parse(_worldState.trader.expiry).toLocal());
_format.format(DateTime.parse(worldState.trader.expiry).toLocal());

Future<Null> update() async {
_isLoading = true;
notifyListeners();

return state.updateState().then((data) async {
_worldState = data;
worldState = data;
_isLoading = false;
_hasError = false;
notifyListeners();
Expand All @@ -131,6 +133,13 @@ class NavisModel extends Model {
@override
void addListener(VoidCallback listener) {
super.addListener(listener);
fcm.configure(
onMessage: (Map<String, dynamic> payload) {
update();
notification.alertNotification(worldState.alerts.first);
},
onResume: (Map<String, dynamic> payload) => update(),
);
}

static NavisModel of(BuildContext context) =>
Expand Down
13 changes: 9 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:package_info/package_info.dart';

import 'app.dart';
import 'model.dart';
import 'services/sentry.dart';
import 'app_model.dart';
import 'network/sentry.dart';
//import 'package:android_job_scheduler/android_job_scheduler.dart';

Future update() async {
Expand All @@ -13,14 +14,18 @@ Future update() async {
}

void main() async {
final package = await PackageInfo.fromPlatform();
ExceptionService.release = package.version;

final exceptionService = ExceptionService();
final model = NavisModel();

await model.update();

runZoned(() => runApp(Navis(model: model)),
/* runZoned(() => runApp(Navis(model: model)),
onError: (error, stackTrace) =>
exceptionService.reportErrorAndStackTrace(error, stackTrace));
exceptionService.reportErrorAndStackTrace(error, stackTrace));*/

runApp(Navis(model: model));
//await AndroidJobScheduler.scheduleEvery(Duration(minutes: 5), 100, update);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions lib/json/void.dart → lib/models/void.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:codable/codable.dart';
class VoidFissures extends Coding {
String node, missionType, enemy, tier, expiry, eta;
int tierNum;
bool expired;

@override
void decode(KeyedArchive object) {
Expand All @@ -15,6 +16,7 @@ class VoidFissures extends Coding {
tierNum = object.decode('tierNum');
expiry = object.decode('expiry');
eta = object.decode('eta');
expired = object.decode('expired');
}

@override
Expand All @@ -26,5 +28,6 @@ class VoidFissures extends Coding {
object.encode('tierNum', tierNum);
object.encode('expiry', expiry);
object.encode('eta', eta);
object.encode('expired', expired);
}
}
File renamed without changes.
8 changes: 5 additions & 3 deletions lib/services/sentry.dart → lib/network/sentry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:sentry/sentry.dart';

import '../util/keys.dart';
import '../resources/keys.dart';

class ExceptionService {
final SentryClient _sentry = new SentryClient(dsn: dsn);
static String release;
final SentryClient _sentry = new SentryClient(
dsn: dsn, environmentAttributes: Event(release: release));

static bool isDebug = false;
static bool isDebug = true;

// Singleton

Expand Down
11 changes: 7 additions & 4 deletions lib/services/state.dart → lib/network/state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import 'dart:convert';

import 'package:codable/codable.dart';
import 'package:http/http.dart' as http;
import 'package:navis/util/preferences.dart';

import '../json/export.dart';
import '../util/keys.dart';
import '../models/export.dart';
import '../resources/keys.dart';
import '../resources/preferences.dart';

class SystemState {
String _platform;
Expand All @@ -32,7 +32,7 @@ class SystemState {
final key = KeyedArchive.unarchive(data);
WorldState state = WorldState()..decode(key);

state.voidFissures.sort((a, b) => a.tierNum.compareTo(b.tierNum));
state.alerts.removeWhere((a) => a.expired == true);

state.news.sort((a, b) => b.date.compareTo(a.date));

Expand All @@ -44,6 +44,9 @@ class SystemState {
state.syndicates
.retainWhere((syndicate) => syndicate.syndicate == 'Ostrons');

state.voidFissures.removeWhere((v) => v.expired == true);
state.voidFissures.sort((a, b) => a.tierNum.compareTo(b.tierNum));

return state;
}

Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion lib/constants.dart → lib/resources/constants.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:navis/util/assets.dart';

import 'assets.dart';

class Constants {
static const List<String> choices = <String>['PC', 'PS4', 'XBox One'];
Expand Down
25 changes: 12 additions & 13 deletions lib/util/dynamicSwitch.dart → lib/resources/factions.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import 'package:flutter/material.dart';

import '../model.dart';
import 'assets.dart';

class DynamicFaction {
final NavisModel _model;

DynamicFaction({@required NavisModel model}) : this._model = model;

sortieColor(Duration timeLeft) {
if (timeLeft >= Duration(hours: 12))
return Colors.green;
Expand All @@ -24,21 +19,25 @@ class DynamicFaction {
else if (timeLeft <= Duration(minutes: 10)) return Colors.red;
}

factionIcon() {
switch (_model.sortie.faction) {
static factionIcon(String faction, {double size}) {
switch (faction) {
case 'Grineer':
return ImageAssets.grineer;
return Icon(ImageAssets.grineer,
size: size, color: factionColor(faction));
case 'Corpus':
return ImageAssets.corpus;
return Icon(ImageAssets.corpus,
size: size, color: factionColor(faction));
case 'Corrupted':
return ImageAssets.corrupted;
return Icon(ImageAssets.corrupted,
size: size, color: factionColor(faction));
default:
return ImageAssets.infested;
return Icon(ImageAssets.infested,
size: size, color: factionColor(faction));
}
}

factionColor() {
switch (_model.sortie.faction) {
static factionColor(String faction) {
switch (faction) {
case 'Corpus':
return Colors.blue[300];
case 'Grineer':
Expand Down
File renamed without changes.
Loading

0 comments on commit a746b31

Please sign in to comment.