diff --git a/lib/file.dart b/lib/file.dart index 38e4f23..6fc6b91 100644 --- a/lib/file.dart +++ b/lib/file.dart @@ -22,6 +22,8 @@ class LineFile extends ChangeNotifier { ItemScrollController scrollController = ItemScrollController(); + var status = ""; + void openFile(String path, int startLine) { this.path = path; File f = File(path); @@ -124,6 +126,8 @@ class LineFile extends ChangeNotifier { } void saveFile() { + status = "Saving..."; + notifyListeners(); String content = ''; String notes = ''; for (var l in backingLines) { @@ -137,6 +141,9 @@ class LineFile extends ChangeNotifier { File("$path.subwrite.notes").writeAsStringSync(notes); File(path).writeAsStringSync(content); + + status = "Saved"; + notifyListeners(); } void handleDelete() { @@ -214,6 +221,9 @@ class LineFile extends ChangeNotifier { } void insertChar(String ch) { + status = "Unsaved Changes"; + notifyListeners(); + var beforeInsertedChar = backingLines[cursor.line - 1].text.substring(0, cursor.column); var afterInsertedChar = backingLines[cursor.line - 1].text.substring(cursor.column); backingLines[cursor.line - 1].text = beforeInsertedChar + ch + afterInsertedChar; @@ -222,6 +232,9 @@ class LineFile extends ChangeNotifier { } void insertLine() { + status = "Unsaved Changes"; + notifyListeners(); + // get the content that will be moved to the next line var restOfLine = backingLines[cursor.line - 1].text.substring(cursor.column); // split off the line after the cursor @@ -236,6 +249,10 @@ class LineFile extends ChangeNotifier { } void renumberFrom(int startLine) { + // Catch many unsaved changes here... + status = "Unsaved Changes"; + notifyListeners(); + for (int line = startLine; line < backingLines.length; line++) { backingLines[line].lineNumber = line + 1; backingLines[line].notifyListeners(); @@ -419,4 +436,8 @@ class LineFile extends ChangeNotifier { description: note)); notifyListeners(); } + + int wordCount() { + return backingLines.map((e) => e.text.trim().split(" ").length).fold(0, (previousValue, element) => previousValue + element); + } } diff --git a/lib/line_info.dart b/lib/line_info.dart index 03ec498..0d93892 100644 --- a/lib/line_info.dart +++ b/lib/line_info.dart @@ -146,9 +146,7 @@ class LineInfo extends ChangeNotifier { child: Row(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( padding: EdgeInsets.zero, - decoration: BoxDecoration( - color: sidebarAlt, - ), + decoration: BoxDecoration(color: sidebarAlt, border: Border(right: BorderSide(width: 1, color: border))), width: gutterWidth - 1, height: idealHeight, margin: EdgeInsets.only(right: 1, top: 0, bottom: 0, left: 0), diff --git a/lib/main.dart b/lib/main.dart index 3d09704..8a26250 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -50,19 +50,50 @@ class _SarahDownApp extends State { Widget build(BuildContext context) { return Material( color: sidebarAlt, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Flexible( - flex: 2, - child: Column( - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.stretch, - mainAxisAlignment: MainAxisAlignment.start, - children: [Expanded(child: Outline()), Container(color: comment)])), - Flexible(flex: 5, child: Editor()) - ], - )); + child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [ + Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Flexible( + flex: 2, + child: Column( + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.stretch, + mainAxisAlignment: MainAxisAlignment.start, + children: [Expanded(child: Outline()), Container(color: comment)])), + Flexible(flex: 5, child: Editor()) + ], + )), + Container( + height: 16, + decoration: BoxDecoration(color: sidebarAlt, border: Border(top: BorderSide(width: 1, color: border))), + child: Padding( + padding: EdgeInsets.symmetric(vertical: 2.0, horizontal: 5.0), + child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + "${Provider.of(context).status}", + textAlign: TextAlign.left, + style: TextStyle( + fontFamily: 'Iosevka', + fontSize: 10, + fontWeight: FontWeight.bold, + color: foreground, + backgroundColor: Colors.transparent, + ), + ), + Text( + "Word Count: ${Provider.of(context).wordCount()}", + textAlign: TextAlign.right, + style: TextStyle( + fontFamily: 'Iosevka', + fontSize: 10, + color: foreground, + backgroundColor: Colors.transparent, + ), + ) + ]))) + ])); } } diff --git a/lib/theme.dart b/lib/theme.dart index 11df891..d1a4b71 100644 --- a/lib/theme.dart +++ b/lib/theme.dart @@ -1,7 +1,7 @@ import 'dart:ui'; Color foreground = const Color(0xfff8f8f2); -Color background = const Color(0xff000000); //Color(0xFF1A0F1C); +Color background = const Color(0xff111111); //Color(0xFF1A0F1C); Color comment = const Color(0xffd684e8); Color selection = const Color(0xff777889); @@ -15,7 +15,8 @@ Color field = header; Color risk = const Color(0xff45353b); -Color sidebarAlt = const Color(0xFF110F15); +Color sidebarAlt = const Color(0xFF070607); Color sidebar = const Color(0xff202023); +Color border = const Color(0xff202023); Color tabs = const Color(0xFF342036); Color sidebarHighlight = const Color(0xFF38213D);