-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor routing to be more reliable and interactive * refactor edit dialogs for all objects to reuse more shared code * add new action buttons to all object views * add file sharing of all current objects (except subItems) * add import dialogs for all current objects (except subItems) * add handler for receiving sharing intents on android * add first test code for an api connection (not usable yet)
- Loading branch information
Showing
98 changed files
with
4,066 additions
and
1,908 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
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 |
---|---|---|
|
@@ -33,6 +33,7 @@ class AppBar extends StatelessWidget { | |
child: child, | ||
), | ||
), | ||
automaticallyImplyLeading: false, | ||
); | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'package:cypher_sheet/components/icon.dart'; | ||
import 'package:cypher_sheet/components/icons.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:share_plus/share_plus.dart'; | ||
|
||
class ShareObjectButton extends StatelessWidget { | ||
const ShareObjectButton(this.getFile, {super.key}); | ||
|
||
final Future<XFile> Function() getFile; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SVGBox( | ||
padding: 12, | ||
onTap: (() async { | ||
Share.shareXFiles(subject: "Shared from Cypher Sheet", [ | ||
await getFile(), | ||
]); | ||
}), | ||
icon: AppIcons.share, | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'package:cypher_sheet/proto/character.pb.dart'; | ||
|
||
extension ShareHelper on Ability { | ||
SharedObject share() { | ||
return SharedObject( | ||
uuid: uuid, | ||
name: name, | ||
ability: this, | ||
); | ||
} | ||
} |
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,11 @@ | ||
import 'package:cypher_sheet/proto/character.pb.dart'; | ||
|
||
extension ShareHelper on Artifact { | ||
SharedObject share() { | ||
return SharedObject( | ||
uuid: uuid, | ||
name: name, | ||
artifact: this, | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,195 @@ | ||
import 'package:cypher_sheet/components/equipment.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:protobuf/protobuf.dart'; | ||
|
||
Map<String, TextEditingController> getEditableTextFieldsFrom( | ||
GeneratedMessage msg) { | ||
final Map<String, TextEditingController> fields = {}; | ||
mergeEditableTextFieldsFrom(msg, fields); | ||
return fields; | ||
} | ||
|
||
void mergeEditableTextFieldsFrom( | ||
GeneratedMessage msg, Map<String, TextEditingController> into) { | ||
// TODO: is byIndex more efficient but still safe? | ||
for (var fieldName in msg.info_.byName.keys) { | ||
final fieldValue = msg.info_.byName[fieldName]; | ||
if (fieldValue == null) { | ||
assert(fieldValue != null); | ||
continue; | ||
} | ||
|
||
if (fieldValue.type != PbFieldType.OS) { | ||
continue; | ||
} | ||
into[fieldName] = | ||
TextEditingController(text: msg.getField(fieldValue.tagNumber)); | ||
} | ||
} | ||
|
||
// Must only be called once per message as it disposes all TextEditingControllers. | ||
Function(String key, TextEditingController value) textFieldsUpdater( | ||
GeneratedMessage msg) { | ||
return (key, value) { | ||
final tagNumber = msg.getTagNumber(key); | ||
if (tagNumber == null) { | ||
assert(tagNumber != null); | ||
return; | ||
} | ||
msg.setField(tagNumber, value.value.text); | ||
value.dispose(); | ||
}; | ||
} | ||
|
||
Map<String, TextEditingController> getEditableDoubleFieldsFrom( | ||
GeneratedMessage msg) { | ||
final Map<String, TextEditingController> fields = {}; | ||
mergeEditableDoubleFieldsFrom(msg, fields); | ||
return fields; | ||
} | ||
|
||
void mergeEditableDoubleFieldsFrom( | ||
GeneratedMessage msg, Map<String, TextEditingController> into) { | ||
// TODO: is byIndex more efficient but still safe? | ||
for (var fieldName in msg.info_.byName.keys) { | ||
final fieldValue = msg.info_.byName[fieldName]; | ||
if (fieldValue == null) { | ||
assert(fieldValue != null); | ||
continue; | ||
} | ||
|
||
if (fieldValue.type != PbFieldType.OD) { | ||
continue; | ||
} | ||
into[fieldName] = TextEditingController( | ||
text: | ||
removeZeroDecimals(msg.getField(fieldValue.tagNumber)).toString()); | ||
} | ||
} | ||
|
||
Function(String key, TextEditingController value) doubleFieldsUpdater( | ||
GeneratedMessage msg) { | ||
return (key, value) { | ||
final tagNumber = msg.getTagNumber(key); | ||
if (tagNumber == null) { | ||
assert(tagNumber != null); | ||
return; | ||
} | ||
final parsed = double.tryParse(value.value.text); | ||
if (value.value.text.isNotEmpty && parsed != null) { | ||
msg.setField(tagNumber, parsed); | ||
} | ||
value.dispose(); | ||
}; | ||
} | ||
|
||
Map<String, bool> getEditableBoolFieldsFrom(GeneratedMessage msg) { | ||
final Map<String, bool> fields = {}; | ||
mergeEditableBoolFieldsFrom(msg, fields); | ||
return fields; | ||
} | ||
|
||
void mergeEditableBoolFieldsFrom(GeneratedMessage msg, Map<String, bool> into) { | ||
// TODO: is byIndex more efficient but still safe? | ||
for (var fieldName in msg.info_.byName.keys) { | ||
final fieldValue = msg.info_.byName[fieldName]; | ||
if (fieldValue == null) { | ||
assert(fieldValue != null); | ||
continue; | ||
} | ||
|
||
if (fieldValue.type != PbFieldType.OB) { | ||
continue; | ||
} | ||
into[fieldName] = msg.getField(fieldValue.tagNumber); | ||
} | ||
} | ||
|
||
Function(String key, bool value) boolFieldsUpdater(GeneratedMessage msg) { | ||
return (key, value) { | ||
final tagNumber = msg.getTagNumber(key); | ||
if (tagNumber == null) { | ||
assert(tagNumber != null); | ||
return; | ||
} | ||
msg.setField(tagNumber, value); | ||
}; | ||
} | ||
|
||
Map<String, TextEditingController> getEditableIntFieldsFrom( | ||
GeneratedMessage msg) { | ||
final Map<String, TextEditingController> fields = {}; | ||
mergeEditableDoubleFieldsFrom(msg, fields); | ||
return fields; | ||
} | ||
|
||
void mergeEditableIntFieldsFrom( | ||
GeneratedMessage msg, Map<String, TextEditingController> into) { | ||
// TODO: is byIndex more efficient but still safe? | ||
for (var fieldName in msg.info_.byName.keys) { | ||
final fieldValue = msg.info_.byName[fieldName]; | ||
if (fieldValue == null) { | ||
assert(fieldValue != null); | ||
continue; | ||
} | ||
|
||
if (fieldValue.type != PbFieldType.OD) { | ||
continue; | ||
} | ||
into[fieldName] = TextEditingController( | ||
text: msg.getField(fieldValue.tagNumber).toString()); | ||
} | ||
} | ||
|
||
Function(String key, TextEditingController value) intFieldsUpdater( | ||
GeneratedMessage msg) { | ||
return (key, value) { | ||
final tagNumber = msg.getTagNumber(key); | ||
if (tagNumber == null) { | ||
assert(tagNumber != null); | ||
return; | ||
} | ||
final parsed = int.tryParse(value.value.text); | ||
if (value.value.text.isNotEmpty && parsed != null) { | ||
msg.setField(tagNumber, parsed); | ||
} | ||
value.dispose(); | ||
}; | ||
} | ||
|
||
void mergeEditableFieldsFrom( | ||
GeneratedMessage msg, { | ||
required Map<String, TextEditingController> strings, | ||
required Map<String, bool> bools, | ||
required Map<String, TextEditingController> doubles, | ||
required Map<String, TextEditingController> ints, | ||
}) { | ||
// TODO: is byIndex more efficient but still safe? | ||
for (var fieldName in msg.info_.byName.keys) { | ||
final fieldValue = msg.info_.byName[fieldName]; | ||
if (fieldValue == null) { | ||
assert(fieldValue != null); | ||
continue; | ||
} | ||
|
||
switch (fieldValue.type) { | ||
case PbFieldType.OS: | ||
strings[fieldName] = | ||
TextEditingController(text: msg.getField(fieldValue.tagNumber)); | ||
break; | ||
case PbFieldType.OB: | ||
bools[fieldName] = msg.getField(fieldValue.tagNumber); | ||
break; | ||
case PbFieldType.OD: | ||
doubles[fieldName] = TextEditingController( | ||
text: removeZeroDecimals(msg.getField(fieldValue.tagNumber)) | ||
.toString()); | ||
break; | ||
case PbFieldType.O3: | ||
ints[fieldName] = TextEditingController( | ||
text: msg.getField(fieldValue.tagNumber).toString()); | ||
break; | ||
default: | ||
} | ||
} | ||
} |
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
Oops, something went wrong.