Skip to content

Commit

Permalink
Merge branch 'dev' into move-svg-position-of-helices-out-of-design-an…
Browse files Browse the repository at this point in the history
…d-into-app-state-#650
  • Loading branch information
dave-doty authored Jan 2, 2022
2 parents d18b38d + 83dce27 commit dc104e2
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/src/actions/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:built_value/serializer.dart';
import 'package:color/color.dart';
import 'package:js/js.dart';
import 'package:built_collection/built_collection.dart';
import 'package:scadnano/src/dna_file_type.dart';
import 'package:scadnano/src/state/domains_move.dart';
import 'package:scadnano/src/state/export_dna_format_strand_order.dart';
import 'package:scadnano/src/state/geometry.dart';
Expand Down
23 changes: 23 additions & 0 deletions lib/src/dna_file_type.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:built_value/built_value.dart';
import 'package:built_collection/built_collection.dart';
import 'package:built_value/serializer.dart';

part 'dna_file_type.g.dart';

class DNAFileType extends EnumClass {
const DNAFileType._(String name) : super(name);

@memoized
int get hashCode;

static Serializer<DNAFileType> get serializer => _$dNAFileTypeSerializer;

/******************** end BuiltValue boilerplate *********************/

static const DNAFileType scadnano_file = _$scadnano_file;
static const DNAFileType cadnano_file = _$cadnano_file;

static BuiltSet<DNAFileType> get values => _$values;
static DNAFileType valueOf(String name) => _$valueOf(name);
}

1 change: 1 addition & 0 deletions lib/src/reducers/load_dna_file_reducer.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:convert';

import 'package:built_collection/built_collection.dart';
import 'package:scadnano/src/dna_file_type.dart';
import '../state/selectable.dart';

import '../state/design.dart';
Expand Down
2 changes: 2 additions & 0 deletions lib/src/serializers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:built_value/serializer.dart';
import 'package:built_collection/built_collection.dart';
import 'package:built_value/standard_json_plugin.dart';
import 'package:color/color.dart';
import 'package:scadnano/src/dna_file_type.dart';
import 'package:tuple/tuple.dart';

import 'state/domains_move.dart';
Expand Down Expand Up @@ -105,6 +106,7 @@ part 'serializers.g.dart';
SetShowEditor,
SaveDNAFile,
LoadDNAFile,
DNAFileType,
ExportCadnanoFile,
ExportCodenanoFile,
MouseoverDataClear,
Expand Down
2 changes: 0 additions & 2 deletions lib/src/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1628,5 +1628,3 @@ Map<int, int> invert_helices_view_order(Iterable<int> helices_view_order) {
}
return view_order_inverse;
}

enum DNAFileType { scadnano_file, cadnano_file }
3 changes: 2 additions & 1 deletion lib/src/view/menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:http/http.dart' as http;
import 'package:path/path.dart' as path;
import 'package:over_react/over_react.dart';
import 'package:over_react/over_react_redux.dart';
import 'package:scadnano/src/dna_file_type.dart';
import 'package:scadnano/src/json_serializable.dart';
import 'package:scadnano/src/state/design.dart';
import 'package:scadnano/src/state/dna_end.dart';
Expand Down Expand Up @@ -1167,7 +1168,7 @@ cadnano_file_loaded(FileReader file_reader, String filename) async {
try {
var json_cadnano_text = file_reader.result;
filename = path.setExtension(filename, '.${constants.default_scadnano_file_extension}');
app.dispatch(actions.LoadDNAFile(content: json_cadnano_text, filename: filename, dna_file_type: util.DNAFileType.cadnano_file));
app.dispatch(actions.LoadDNAFile(content: json_cadnano_text, filename: filename, dna_file_type: DNAFileType.cadnano_file));
} on Exception catch (e) {
window.alert('Error importing file: ${e}');
}
Expand Down

0 comments on commit dc104e2

Please sign in to comment.