Skip to content

Commit

Permalink
Some Changes
Browse files Browse the repository at this point in the history
- Remove old search history when application loaded.
- My Words items are now sorted - recent items are at top.
  • Loading branch information
omidgolparvar committed Jul 25, 2019
1 parent c0ffb42 commit 1b16aab
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 32 deletions.
Binary file not shown.
4 changes: 2 additions & 2 deletions Vazhegan/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.1</string>
<string>2.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -32,7 +32,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>413</string>
<string>418</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
14 changes: 7 additions & 7 deletions Vazhegan/Storyboards/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,13 @@
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="کلمه نمونه" textAlignment="right" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="u2T-C0-8UO">
<rect key="frame" x="16" y="44" width="343" height="37.5"/>
<rect key="frame" x="16" y="44" width="343" height="40.5"/>
<fontDescription key="fontDescription" name="IRANSansMobile-Bold" family="IRANSansMobile" pointSize="32"/>
<color key="textColor" red="0.0" green="0.70980392160000005" blue="0.76078431369999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0PQ-EH-Jd1">
<rect key="frame" x="16" y="41" width="44" height="44"/>
<rect key="frame" x="16" y="42.5" width="44" height="44"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.10000000000000001" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="EAp-fA-bt0"/>
Expand All @@ -491,23 +491,23 @@
</connections>
</button>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" text="این یک معنی نمونه است که می‌تواند دارای بیشتر از یک خط نیز باشد و باید بدرستی نمایش داده شود." textAlignment="right" translatesAutoresizingMaskIntoConstraints="NO" id="vio-1H-e4l">
<rect key="frame" x="16" y="150.5" width="343" height="427.5"/>
<rect key="frame" x="16" y="153.5" width="343" height="424.5"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" name="IRANSansMobile" family="IRANSansMobile" pointSize="16"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hml-Bx-Pmd">
<rect key="frame" x="16" y="149.5" width="343" height="1"/>
<rect key="frame" x="16" y="152.5" width="343" height="1"/>
<color key="backgroundColor" red="0.92143100499999997" green="0.92145264149999995" blue="0.92144101860000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="M8z-hd-ad5"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bNT-me-GpH">
<rect key="frame" x="259.5" y="97.5" width="99.5" height="36"/>
<rect key="frame" x="241.5" y="100.5" width="117.5" height="36"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="عنوان لغت‌نامه" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="F6j-7z-ANk">
<rect key="frame" x="12" y="0.0" width="75.5" height="36"/>
<rect key="frame" x="12" y="0.0" width="93.5" height="36"/>
<fontDescription key="fontDescription" name="IRANSansMobile" family="IRANSansMobile" pointSize="16"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -567,7 +567,7 @@
<scene sceneID="9Ni-Vo-Ahx">
<objects>
<tableViewController storyboardIdentifier="MyWordsController" id="6AP-HH-FKt" customClass="MyWordsController" customModule="Vazhegan" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="3ja-5x-P0g">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="70" estimatedRowHeight="70" sectionHeaderHeight="28" sectionFooterHeight="28" id="3ja-5x-P0g">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
Expand Down
33 changes: 16 additions & 17 deletions Vazhegan/Views/MyWordCell.xib
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<customFonts key="customFonts">
<array key="IRANSansMobile.ttf">
<string>IRANSansMobile</string>
</array>
<array key="IRANSansMobile_Bold.ttf">
<string>IRANSansMobile-Bold</string>
</array>
<array key="IRANSansMobile_Medium.ttf">
<string>IRANSansMobile-Medium</string>
</array>
</customFonts>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" rowHeight="120" id="KGk-i7-Jjw" customClass="MyWordCell" customModule="Vazhegan" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="120"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" rowHeight="70" id="KGk-i7-Jjw" customClass="MyWordCell" customModule="Vazhegan" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="70"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="119.5"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="69.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="کلمه نمونه" textAlignment="right" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1AF-Oo-wok">
<rect key="frame" x="16" y="16" width="288" height="43.5"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="کلمه نمونه" textAlignment="right" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1AF-Oo-wok">
<rect key="frame" x="118" y="22" width="186" height="25.5"/>
<fontDescription key="fontDescription" name="IRANSansMobile-Bold" family="IRANSansMobile" pointSize="20"/>
<color key="textColor" red="0.25449702140000002" green="0.1572966576" blue="0.60395795109999995" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ECg-sb-WN1">
<rect key="frame" x="198.5" y="71.5" width="105.5" height="32"/>
<rect key="frame" x="12" y="19" width="94" height="32"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="عنوان لغت‌نامه" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Vpi-EG-H5O">
<rect key="frame" x="12" y="0.0" width="81.5" height="32"/>
<fontDescription key="fontDescription" name="IRANSansMobile" family="IRANSansMobile" pointSize="14"/>
<rect key="frame" x="12" y="0.0" width="70" height="32"/>
<fontDescription key="fontDescription" name="IRANSansMobile-Medium" family="IRANSansMobile" pointSize="12"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
Expand All @@ -55,11 +55,10 @@
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="1AF-Oo-wok" secondAttribute="trailing" constant="16" id="0IQ-sS-ma6"/>
<constraint firstItem="ECg-sb-WN1" firstAttribute="top" secondItem="1AF-Oo-wok" secondAttribute="bottom" constant="12" id="EaP-RQ-vYs"/>
<constraint firstAttribute="bottom" secondItem="ECg-sb-WN1" secondAttribute="bottom" constant="16" id="FNh-dm-FtK"/>
<constraint firstItem="1AF-Oo-wok" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="T6M-GB-U7Q"/>
<constraint firstAttribute="trailing" secondItem="ECg-sb-WN1" secondAttribute="trailing" constant="16" id="gC6-uU-fwh"/>
<constraint firstItem="1AF-Oo-wok" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="16" id="sJY-hZ-vsf"/>
<constraint firstItem="1AF-Oo-wok" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="8Du-fT-sJH"/>
<constraint firstItem="1AF-Oo-wok" firstAttribute="leading" secondItem="ECg-sb-WN1" secondAttribute="trailing" constant="12" id="ONZ-Af-NMv"/>
<constraint firstItem="ECg-sb-WN1" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="12" id="TM6-18-ffd"/>
<constraint firstItem="ECg-sb-WN1" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="vcb-yi-XCQ"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
Expand All @@ -68,7 +67,7 @@
<outlet property="label_Title" destination="1AF-Oo-wok" id="xio-Yd-5w9"/>
<outlet property="view_DatabaseNameHolder" destination="ECg-sb-WN1" id="pCh-9Q-KHj"/>
</connections>
<point key="canvasLocation" x="137.59999999999999" y="139.43028485757122"/>
<point key="canvasLocation" x="137.59999999999999" y="131.33433283358323"/>
</tableViewCell>
</objects>
</document>
4 changes: 2 additions & 2 deletions VazheganActionExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>2.1</string>
<string>2.2</string>
<key>CFBundleVersion</key>
<string>413</string>
<string>418</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
Expand Down
12 changes: 12 additions & 0 deletions VazheganFramework/Models/Query.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ extension Query {
return array
}

public static func DeleteOldItems() {
let allQueries = V.RealmObject.objects(Query.self)
guard allQueries.count > 50 else { return }
var oldItems: [Query] = []
allQueries[50...].forEach {
oldItems.append($0)
}
V.RealmObject.safeWrite {
V.RealmObject.delete(oldItems)
}
}

public static func DeleteAll() {
let allQueries = V.RealmObject.objects(Query.self)
V.RealmObject.safeWrite {
Expand Down
2 changes: 2 additions & 0 deletions VazheganFramework/Models/V.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ public class V {

public static func Setup() {
Database.Setup()
Query.DeleteOldItems()
}

public static func HandleIncomingURL(_ url: URL) {
//Pattern > vazhegan://getMeaning/{text}

guard
let host = url.host?.lowercased(),
host == "getMeaning".lowercased(),
Expand Down
9 changes: 5 additions & 4 deletions VazheganFramework/Models/Word.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public final class Word: Object {
@objc dynamic public var text : String = ""
@objc dynamic public var source : String = ""
@objc dynamic public var number : Int = 0

@objc dynamic public var pronounce : String = ""
@objc dynamic public var fullText : String = ""

Expand Down Expand Up @@ -86,8 +85,8 @@ public final class Word: Object {
let _fullText = dynamicJSON.word?.text?.json?.string
else { return false }

pronounce = _pronounce
fullText = _fullText
pronounce = _pronounce
fullText = _fullText

return true
}
Expand Down Expand Up @@ -161,7 +160,9 @@ extension Word {

public static var MyWords: [Word] {
var result: [Word] = []
V.RealmObject.objects(Word.self).forEach { result.append($0) }
V.RealmObject.objects(Word.self)
.reversed()
.forEach { result.append($0) }
return result
}

Expand Down

0 comments on commit 1b16aab

Please sign in to comment.