Skip to content

Commit

Permalink
Merge pull request #13 from betzerra/feat-ui-improved
Browse files Browse the repository at this point in the history
Huge UI refactor
  • Loading branch information
betzerra committed Oct 28, 2021
2 parents 09dfe7a + 5ad9125 commit 329b90a
Show file tree
Hide file tree
Showing 16 changed files with 386 additions and 408 deletions.
56 changes: 18 additions & 38 deletions Morty.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,23 @@
objects = {

/* Begin PBXBuildFile section */
6707F1D52727648D00953418 /* MenuDayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6707F1D42727648D00953418 /* MenuDayView.swift */; };
6707F1D7272768F600953418 /* MenuDayViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6707F1D6272768F600953418 /* MenuDayViewModel.swift */; };
67121AD9266F14AE00004442 /* MenuViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67121AD8266F14AE00004442 /* MenuViewModel.swift */; };
671856FB26606048005EB677 /* EventsHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 671856FA26606048005EB677 /* EventsHelper.swift */; };
671856FE2660608D005EB677 /* EventsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 671856FD2660608D005EB677 /* EventsManager.swift */; };
6718A54E266BD701007161B1 /* Event.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6718A54D266BD701007161B1 /* Event.swift */; };
6718A550266BD899007161B1 /* EventTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6718A54F266BD899007161B1 /* EventTests.swift */; };
6718A555266BDE9B007161B1 /* Bundle+Content.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6718A554266BDE9B007161B1 /* Bundle+Content.swift */; };
6718A556266BE0D9007161B1 /* Event_mock_001.json in Resources */ = {isa = PBXBuildFile; fileRef = 6718A551266BD8E2007161B1 /* Event_mock_001.json */; };
6718A559266BE384007161B1 /* Date+Formats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6718A558266BE384007161B1 /* Date+Formats.swift */; };
6718A55B266BE498007161B1 /* JSONDecoder+Standard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6718A55A266BE498007161B1 /* JSONDecoder+Standard.swift */; };
6718A55E266BED68007161B1 /* Array_events_mock_001.json in Resources */ = {isa = PBXBuildFile; fileRef = 6718A55D266BED68007161B1 /* Array_events_mock_001.json */; };
6718A560266BEF38007161B1 /* Day.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6718A55F266BEF38007161B1 /* Day.swift */; };
673BBA08265F432200F22219 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 673BBA07265F432200F22219 /* AppDelegate.swift */; };
673BBA0C265F432300F22219 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 673BBA0B265F432300F22219 /* Assets.xcassets */; };
673BBA0F265F432300F22219 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 673BBA0D265F432300F22219 /* Main.storyboard */; };
673BBA1B265F432300F22219 /* MortyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 673BBA1A265F432300F22219 /* MortyTests.swift */; };
673BBA26265F432300F22219 /* MortyUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 673BBA25265F432300F22219 /* MortyUITests.swift */; };
67475844271267920015C20E /* DayEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67475843271267920015C20E /* DayEventHandler.swift */; };
678B31EA2724870400CC0574 /* CalendarPickerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 678B31E92724870400CC0574 /* CalendarPickerViewModel.swift */; };
678B31EC2724960700CC0574 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 678B31EB2724960700CC0574 /* Settings.swift */; };
678B31EE2724A75B00CC0574 /* EKCalendar+View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 678B31ED2724A75B00CC0574 /* EKCalendar+View.swift */; };
67DB4CA1272774FA001E62BD /* String+Symbols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67DB4CA0272774FA001E62BD /* String+Symbols.swift */; };
67EF68F7267678090005F99F /* CalendarPickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67EF68F6267678090005F99F /* CalendarPickerViewController.swift */; };
/* End PBXBuildFile section */

Expand All @@ -48,17 +45,14 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
6707F1D42727648D00953418 /* MenuDayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuDayView.swift; sourceTree = "<group>"; };
6707F1D6272768F600953418 /* MenuDayViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuDayViewModel.swift; sourceTree = "<group>"; };
67121AD8266F14AE00004442 /* MenuViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuViewModel.swift; sourceTree = "<group>"; };
671856FA26606048005EB677 /* EventsHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventsHelper.swift; sourceTree = "<group>"; };
671856FD2660608D005EB677 /* EventsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventsManager.swift; sourceTree = "<group>"; };
6718A54D266BD701007161B1 /* Event.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Event.swift; sourceTree = "<group>"; };
6718A54F266BD899007161B1 /* EventTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventTests.swift; sourceTree = "<group>"; };
6718A551266BD8E2007161B1 /* Event_mock_001.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = Event_mock_001.json; sourceTree = "<group>"; };
6718A554266BDE9B007161B1 /* Bundle+Content.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+Content.swift"; sourceTree = "<group>"; };
6718A558266BE384007161B1 /* Date+Formats.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+Formats.swift"; sourceTree = "<group>"; };
6718A55A266BE498007161B1 /* JSONDecoder+Standard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "JSONDecoder+Standard.swift"; sourceTree = "<group>"; };
6718A55D266BED68007161B1 /* Array_events_mock_001.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Array_events_mock_001.json; sourceTree = "<group>"; };
6718A55F266BEF38007161B1 /* Day.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Day.swift; sourceTree = "<group>"; };
673BBA04265F432200F22219 /* Morty.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Morty.app; sourceTree = BUILT_PRODUCTS_DIR; };
673BBA07265F432200F22219 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
673BBA0B265F432300F22219 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand All @@ -71,10 +65,10 @@
673BBA21265F432300F22219 /* MortyUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MortyUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
673BBA25265F432300F22219 /* MortyUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MortyUITests.swift; sourceTree = "<group>"; };
673BBA27265F432300F22219 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
67475843271267920015C20E /* DayEventHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DayEventHandler.swift; sourceTree = "<group>"; };
678B31E92724870400CC0574 /* CalendarPickerViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarPickerViewModel.swift; sourceTree = "<group>"; };
678B31EB2724960700CC0574 /* Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = "<group>"; };
678B31ED2724A75B00CC0574 /* EKCalendar+View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EKCalendar+View.swift"; sourceTree = "<group>"; };
67DB4CA0272774FA001E62BD /* String+Symbols.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Symbols.swift"; sourceTree = "<group>"; };
67EF68F6267678090005F99F /* CalendarPickerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarPickerViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -103,13 +97,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
671856F926606031005EB677 /* Helpers */ = {
6707F1D32727644200953418 /* MenuView */ = {
isa = PBXGroup;
children = (
671856FA26606048005EB677 /* EventsHelper.swift */,
67475843271267920015C20E /* DayEventHandler.swift */,
67121AD8266F14AE00004442 /* MenuViewModel.swift */,
6707F1D42727648D00953418 /* MenuDayView.swift */,
6707F1D6272768F600953418 /* MenuDayViewModel.swift */,
);
path = Helpers;
path = MenuView;
sourceTree = "<group>";
};
671856FC2660607D005EB677 /* Managers */ = {
Expand All @@ -124,7 +119,6 @@
6718A54C266BD6D3007161B1 /* Models */ = {
isa = PBXGroup;
children = (
6718A55F266BEF38007161B1 /* Day.swift */,
6718A54D266BD701007161B1 /* Event.swift */,
);
path = Models;
Expand All @@ -134,21 +128,14 @@
isa = PBXGroup;
children = (
6718A554266BDE9B007161B1 /* Bundle+Content.swift */,
67DB4CA0272774FA001E62BD /* String+Symbols.swift */,
678B31ED2724A75B00CC0574 /* EKCalendar+View.swift */,
6718A558266BE384007161B1 /* Date+Formats.swift */,
6718A55A266BE498007161B1 /* JSONDecoder+Standard.swift */,
);
path = Extensions;
sourceTree = "<group>";
};
671C5C0E266C45270029F6B8 /* ViewModels */ = {
isa = PBXGroup;
children = (
67121AD8266F14AE00004442 /* MenuViewModel.swift */,
);
path = ViewModels;
sourceTree = "<group>";
};
673BB9FB265F432200F22219 = {
isa = PBXGroup;
children = (
Expand All @@ -173,15 +160,14 @@
isa = PBXGroup;
children = (
673BBA07265F432200F22219 /* AppDelegate.swift */,
678B31E8272486ED00CC0574 /* CalendarPicker */,
6718A553266BDE85007161B1 /* Extensions */,
6718A54C266BD6D3007161B1 /* Models */,
671856F926606031005EB677 /* Helpers */,
671856FC2660607D005EB677 /* Managers */,
6707F1D32727644200953418 /* MenuView */,
6718A54C266BD6D3007161B1 /* Models */,
673BBA0B265F432300F22219 /* Assets.xcassets */,
673BBA0D265F432300F22219 /* Main.storyboard */,
673BBA10265F432300F22219 /* Info.plist */,
678B31E8272486ED00CC0574 /* CalendarPicker */,
671C5C0E266C45270029F6B8 /* ViewModels */,
673BBA11265F432300F22219 /* Morty.entitlements */,
);
path = Morty;
Expand All @@ -191,9 +177,6 @@
isa = PBXGroup;
children = (
673BBA1A265F432300F22219 /* MortyTests.swift */,
6718A54F266BD899007161B1 /* EventTests.swift */,
6718A55D266BED68007161B1 /* Array_events_mock_001.json */,
6718A551266BD8E2007161B1 /* Event_mock_001.json */,
673BBA1C265F432300F22219 /* Info.plist */,
);
path = MortyTests;
Expand Down Expand Up @@ -330,8 +313,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6718A55E266BED68007161B1 /* Array_events_mock_001.json in Resources */,
6718A556266BE0D9007161B1 /* Event_mock_001.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -369,19 +350,19 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
67475844271267920015C20E /* DayEventHandler.swift in Sources */,
6707F1D7272768F600953418 /* MenuDayViewModel.swift in Sources */,
6707F1D52727648D00953418 /* MenuDayView.swift in Sources */,
6718A555266BDE9B007161B1 /* Bundle+Content.swift in Sources */,
678B31EE2724A75B00CC0574 /* EKCalendar+View.swift in Sources */,
67DB4CA1272774FA001E62BD /* String+Symbols.swift in Sources */,
678B31EC2724960700CC0574 /* Settings.swift in Sources */,
6718A54E266BD701007161B1 /* Event.swift in Sources */,
6718A560266BEF38007161B1 /* Day.swift in Sources */,
678B31EA2724870400CC0574 /* CalendarPickerViewModel.swift in Sources */,
673BBA08265F432200F22219 /* AppDelegate.swift in Sources */,
67EF68F7267678090005F99F /* CalendarPickerViewController.swift in Sources */,
6718A55B266BE498007161B1 /* JSONDecoder+Standard.swift in Sources */,
67121AD9266F14AE00004442 /* MenuViewModel.swift in Sources */,
671856FE2660608D005EB677 /* EventsManager.swift in Sources */,
671856FB26606048005EB677 /* EventsHelper.swift in Sources */,
6718A559266BE384007161B1 /* Date+Formats.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -390,7 +371,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6718A550266BD899007161B1 /* EventTests.swift in Sources */,
673BBA1B265F432300F22219 /* MortyTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
10 changes: 2 additions & 8 deletions Morty/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Cocoa

@main
class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
class AppDelegate: NSObject, NSApplicationDelegate {

static var current: AppDelegate {
guard let appDelegate = NSApplication.shared.delegate as? AppDelegate else {
Expand Down Expand Up @@ -37,7 +37,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {

menuViewModel = MenuViewModel(
menu: menu,
eventsPublisher: eventsManager.dayEventsFetched
eventsPublisher: eventsManager.eventsFetched
)

eventsManager.updateDayEvents()
Expand All @@ -57,11 +57,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
}
}

// MARK: NSMenuDelegate
func menuWillOpen(_ menu: NSMenu) {
eventsManager.updateDayEvents()
}

// MARK: Private
private func setupStatusItem() {
// Set status item
Expand All @@ -74,7 +69,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
// Set menu when icon is clicked
if let menu = menu {
statusItem?.menu = menu
menu.delegate = self
}
}
}
30 changes: 19 additions & 11 deletions Morty/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="19455" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19162"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19455"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -22,19 +22,28 @@
<action selector="preferencesTapped:" target="Voe-Tx-rLC" id="NtG-w3-NTr"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="vdt-GS-N5Z"/>
<menuItem title="Yesterday" tag="9" enabled="NO" id="hfn-GT-qK8">
<menuItem isSeparatorItem="YES" id="uCo-LL-WdS"/>
<menuItem title="Yesterday" tag="1" id="BQk-77-56i">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="􀉄 Copy yesterday's items." tag="10" id="biT-tt-NXL">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="xwP-WH-vvU"/>
<menuItem title="Today" tag="2" id="ppN-Rh-81O">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="􀉄 Copy today's items." tag="20" id="HCZ-3f-396">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="BpR-yd-Ttj"/>
<menuItem title="Today" tag="10" enabled="NO" id="vAF-4J-DOU">
<menuItem isSeparatorItem="YES" id="NVS-SI-gcV"/>
<menuItem title="Tomorrow" tag="3" id="3Ox-ph-Xzh">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
<menuItem title="Tomorrow" tag="11" enabled="NO" id="cWs-hM-eWY">
<menuItem title="􀉄 Copy tomorrow's items." tag="30" id="Tge-JN-cl9">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="cB8-Pd-OL0"/>
<menuItem isSeparatorItem="YES" id="vdt-GS-N5Z"/>
<menuItem title="Quit Morty" keyEquivalent="q" id="4sb-4s-VLi">
<connections>
<action selector="terminate:" target="Ady-hI-5gd" id="Te7-pn-YzF"/>
Expand All @@ -52,7 +61,6 @@
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="Morty" customModuleProvider="target">
<connections>
<outlet property="menu" destination="uQy-DD-JDr" id="oTG-G6-mga"/>
<outlet property="todayMenuItem" destination="vAF-4J-DOU" id="Hf7-ms-7ok"/>
</connections>
</customObject>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
Expand Down Expand Up @@ -204,7 +212,7 @@
<tableColumnResizingMask key="resizingMask" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="calendarIdentifier" id="TCo-cj-QXI">
<rect key="frame" x="18" y="0.0" width="449" height="24"/>
<rect key="frame" x="8" y="0.0" width="449" height="24"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button verticalHuggingPriority="750" id="Prn-tQ-bD4">
Expand Down
23 changes: 23 additions & 0 deletions Morty/Extensions/String+Symbols.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// NSAttributedString.swift
// Morty
//
// Created by Ezequiel Becerra on 25/10/2021.
//

import Foundation
import AppKit

extension String {

func attributed(leadingSymbol symbolName: String) -> NSAttributedString {
let imageAttachment = NSTextAttachment()
imageAttachment.image = NSImage(systemSymbolName: symbolName, accessibilityDescription: nil)

let attributed = NSMutableAttributedString()
attributed.append(NSAttributedString(attachment: imageAttachment))
attributed.append(NSAttributedString(string: " \(self)"))

return attributed
}
}

0 comments on commit 329b90a

Please sign in to comment.