-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from dominik-masson/develop
NEW: images for entries a backup of the database is automatically created as soon as the app is closed reset an entry and/or mark an entry as sent to the provider archive meters compare contacts, Update UI: new entrycard design add dynamic color material 3 bottom app bar new database settings screen new object screens for rooms and contracts new details page for contracts meter units are now displayed more nicely also a few bugs have been fixed
- Loading branch information
Showing
160 changed files
with
15,084 additions
and
4,550 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,110 @@ | ||
import 'package:drift/drift.dart'; | ||
|
||
import '../../model/compare_costs.dart'; | ||
import '../../model/contract_dto.dart'; | ||
import '../../model/provider_dto.dart'; | ||
import '../local_database.dart'; | ||
import '../tables/contract.dart'; | ||
|
||
part 'contract_dao.g.dart'; | ||
|
||
@DriftAccessor(tables: [Contract, Provider]) | ||
class ContractDao extends DatabaseAccessor<LocalDatabase> with _$ContractDaoMixin{ | ||
class ContractDao extends DatabaseAccessor<LocalDatabase> | ||
with _$ContractDaoMixin { | ||
final LocalDatabase db; | ||
|
||
ContractDao(this.db) : super(db); | ||
|
||
Future<int> createProvider(ProviderCompanion provider) async{ | ||
Future<int> createProvider(ProviderCompanion provider) async { | ||
return await db.into(db.provider).insert(provider); | ||
} | ||
|
||
Future<int> createContract(ContractCompanion contract) async { | ||
return await db.into(db.contract).insert(contract); | ||
} | ||
|
||
Stream<List<ContractData>> watchALlContracts() { | ||
return db.select(db.contract).watch(); | ||
Stream<List<ContractData>> watchAllContracts(bool isArchived) { | ||
return (select(db.contract) | ||
..where((tbl) => tbl.isArchived.equals(isArchived))) | ||
.watch(); | ||
} | ||
|
||
Future<List<ContractDto>> getAllContractsDto() async { | ||
List<ContractDto> result = []; | ||
List<ContractData> contracts = await select(db.contract).get(); | ||
|
||
for (ContractData contract in contracts) { | ||
ContractDto contractDto = ContractDto.fromData(contract, null); | ||
|
||
if (contract.provider != null) { | ||
ProviderData provider = await selectProvider(contract.provider!); | ||
|
||
contractDto.provider = ProviderDto.fromData(provider); | ||
} | ||
|
||
final compareCosts = await db.costCompareDao.getCompareCost(contract.id); | ||
|
||
if (compareCosts != null) { | ||
contractDto.compareCosts = CompareCosts.fromData(compareCosts); | ||
} | ||
|
||
result.add(contractDto); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
Future<ProviderData> selectProvider(int id) async { | ||
return await (db.select(db.provider)..where((tbl) => tbl.uid.equals(id))).getSingle(); | ||
return await (db.select(db.provider)..where((tbl) => tbl.id.equals(id))) | ||
.getSingle(); | ||
} | ||
|
||
Future<int> deleteContract(int id) async { | ||
return await (db.delete(db.contract)..where((tbl) => tbl.uid.equals(id))).go(); | ||
return await (db.delete(db.contract)..where((tbl) => tbl.id.equals(id))) | ||
.go(); | ||
} | ||
|
||
Future<int> deleteProvider(int id) async { | ||
return await (db.delete(db.provider)..where((tbl) => tbl.uid.equals(id))).go(); | ||
return await (db.delete(db.provider)..where((tbl) => tbl.id.equals(id))) | ||
.go(); | ||
} | ||
|
||
Future<ContractData> getContractByTyp(String meterTyp) async { | ||
return await (db.select(db.contract)..where((tbl) => tbl.meterTyp.equals(meterTyp))).getSingle(); | ||
return await (db.select(db.contract) | ||
..where((tbl) => tbl.meterTyp.equals(meterTyp))) | ||
.getSingle(); | ||
} | ||
|
||
Future<bool> updateContract(ContractData contractData) async{ | ||
Future<bool> updateContract(ContractData contractData) async { | ||
return await update(db.contract).replace(contractData); | ||
} | ||
|
||
Future<bool> updateProvider(ProviderData providerData) async { | ||
return await update(db.provider).replace(providerData); | ||
} | ||
} | ||
|
||
Future<int?> getTableLength() async { | ||
var count = db.contract.id.count(); | ||
|
||
return await (db.selectOnly(db.contract)..addColumns([count])) | ||
.map((row) => row.read(count)) | ||
.getSingleOrNull(); | ||
} | ||
|
||
Future<int> linkProviderToContract( | ||
{required int contractId, required int providerId}) async { | ||
return await (update(db.contract) | ||
..where((tbl) => tbl.id.equals(contractId))) | ||
.write( | ||
ContractCompanion( | ||
provider: Value(providerId), | ||
), | ||
); | ||
} | ||
|
||
Future updateIsArchived( | ||
{required int contractId, required bool isArchived}) async { | ||
return await (update(contract)..where((tbl) => tbl.id.equals(contractId))) | ||
.write(ContractCompanion(isArchived: Value(isArchived))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:drift/drift.dart'; | ||
|
||
import '../local_database.dart'; | ||
import '../tables/cost_compare.dart'; | ||
|
||
part 'cost_compare_dao.g.dart'; | ||
|
||
@DriftAccessor(tables: [CostCompare]) | ||
class CostCompareDao extends DatabaseAccessor<LocalDatabase> | ||
with _$CostCompareDaoMixin { | ||
final LocalDatabase db; | ||
|
||
CostCompareDao(this.db) : super(db); | ||
|
||
Future<CostCompareData?> getCompareCost(int parentId) async { | ||
return await (select(db.costCompare) | ||
..where((tbl) => tbl.parentId.equals(parentId))) | ||
.getSingleOrNull(); | ||
} | ||
|
||
Future createCompareCost(CostCompareCompanion costs) async { | ||
return await into(db.costCompare).insert(costs); | ||
} | ||
|
||
Future deleteCompareCost(int id) async { | ||
return await (delete(db.costCompare)..where((tbl) => tbl.id.equals(id))) | ||
.go(); | ||
} | ||
|
||
Future updateCompareCost(CostCompareData cost) async { | ||
return await update(db.costCompare).replace(cost); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.