macOS widgets
This commit is contained in:
parent
95fc7a59d1
commit
4bddd3ff8c
|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/company_model.dart';
|
import 'package:invoiceninja_flutter/data/models/company_model.dart';
|
||||||
|
import 'package:invoiceninja_flutter/data/models/static/currency_model.dart';
|
||||||
import 'package:invoiceninja_flutter/main_app.dart';
|
import 'package:invoiceninja_flutter/main_app.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
|
|
@ -139,10 +140,8 @@ class WidgetCompany {
|
||||||
userCompanyState.clientState.map,
|
userCompanyState.clientState.map,
|
||||||
userCompanyState.groupState.map,
|
userCompanyState.groupState.map,
|
||||||
).where((currencyId) => currencyId != kCurrencyAll))
|
).where((currencyId) => currencyId != kCurrencyAll))
|
||||||
currencyId: WidgetCurrency(
|
currencyId: WidgetCurrency.fromCurrency(
|
||||||
id: currencyId,
|
staticState.currencyMap[currencyId],
|
||||||
name: staticState.currencyMap[currencyId].name,
|
|
||||||
exchangeRate: staticState.currencyMap[currencyId].exchangeRate,
|
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -172,20 +171,34 @@ class WidgetCompany {
|
||||||
}
|
}
|
||||||
|
|
||||||
class WidgetCurrency {
|
class WidgetCurrency {
|
||||||
WidgetCurrency({this.id, this.name, this.exchangeRate});
|
WidgetCurrency({
|
||||||
|
this.id,
|
||||||
|
this.name,
|
||||||
|
this.code,
|
||||||
|
this.exchangeRate,
|
||||||
|
});
|
||||||
|
|
||||||
|
WidgetCurrency.fromCurrency(CurrencyEntity currency)
|
||||||
|
: id = currency.id,
|
||||||
|
name = currency.name,
|
||||||
|
code = currency.code,
|
||||||
|
exchangeRate = currency.exchangeRate;
|
||||||
|
|
||||||
WidgetCurrency.fromJson(Map<String, dynamic> json)
|
WidgetCurrency.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
name = json['name'],
|
name = json['name'],
|
||||||
|
code = json['code'],
|
||||||
exchangeRate = json['exchange_rate'];
|
exchangeRate = json['exchange_rate'];
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||||
'id': id,
|
'id': id,
|
||||||
'name': name,
|
'name': name,
|
||||||
|
'code': code,
|
||||||
'exchange_rate': exchangeRate,
|
'exchange_rate': exchangeRate,
|
||||||
};
|
};
|
||||||
|
|
||||||
final String id;
|
final String id;
|
||||||
final String name;
|
final String name;
|
||||||
|
final String code;
|
||||||
final double exchangeRate;
|
final double exchangeRate;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -169,11 +169,13 @@ struct WidgetCompany: Decodable, Hashable {
|
||||||
struct WidgetCurrency: Decodable, Hashable {
|
struct WidgetCurrency: Decodable, Hashable {
|
||||||
let id: String
|
let id: String
|
||||||
let name: String
|
let name: String
|
||||||
|
let code: String
|
||||||
let exchangeRate: Double
|
let exchangeRate: Double
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case id
|
case id
|
||||||
case name
|
case name
|
||||||
|
case code
|
||||||
case exchangeRate = "exchange_rate"
|
case exchangeRate = "exchange_rate"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -190,6 +192,7 @@ struct DashboardWidgetEntryView : View {
|
||||||
var entry: Provider.Entry
|
var entry: Provider.Entry
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
/*
|
||||||
//Text(entry.widgetData?.tokens.keys.joined() ?? "BLANK")
|
//Text(entry.widgetData?.tokens.keys.joined() ?? "BLANK")
|
||||||
//Text("TEST \(entry.configuration.field.rawValue)")
|
//Text("TEST \(entry.configuration.field.rawValue)")
|
||||||
VStack {
|
VStack {
|
||||||
|
|
@ -199,22 +202,22 @@ struct DashboardWidgetEntryView : View {
|
||||||
Text(entry.configuration.company?.displayString ?? "")
|
Text(entry.configuration.company?.displayString ?? "")
|
||||||
Text(entry.widgetData?.url ?? "")
|
Text(entry.widgetData?.url ?? "")
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
ZStack {
|
ZStack {
|
||||||
Rectangle().fill(BackgroundStyle())
|
Rectangle().fill(BackgroundStyle())
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
Text("Balance")
|
Text(entry.field)
|
||||||
.font(.largeTitle)
|
.font(.body)
|
||||||
.fontWeight(.bold)
|
.bold()
|
||||||
.foregroundColor(Color.blue)
|
.foregroundColor(Color.blue)
|
||||||
Text("$123.00")
|
Text("\(entry.value)")
|
||||||
|
.font(.title)
|
||||||
.privacySensitive()
|
.privacySensitive()
|
||||||
.font(.title2)
|
|
||||||
.foregroundColor(Color.gray)
|
.foregroundColor(Color.gray)
|
||||||
|
.minimumScaleFactor(0.8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue