Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
Add reminder to save changes when editting a product
Browse files Browse the repository at this point in the history
Closes #30
  • Loading branch information
tovkal committed Oct 20, 2017
1 parent d1e98ba commit 371185e
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 12 deletions.
4 changes: 4 additions & 0 deletions OpenFoodFacts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
9525708C1EE9BC91002FC40D /* CellImageTapable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9525708B1EE9BC91002FC40D /* CellImageTapable.swift */; };
9528560B1F78512300863FC6 /* Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9528560A1F78512300863FC6 /* Array.swift */; };
9528560E1F798EAA00863FC6 /* SummaryFormTableViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9528560D1F798EAA00863FC6 /* SummaryFormTableViewControllerTests.swift */; };
952C3BE91F9A335F003C755A /* UIViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952C3BE81F9A335F003C755A /* UIViewController.swift */; };
953498F91F76967A00568C35 /* NavigationControllerMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 953498F81F76967A00568C35 /* NavigationControllerMock.swift */; };
953498FC1F77AFF900568C35 /* ProductDetailViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 953498FB1F77AFF900568C35 /* ProductDetailViewControllerTests.swift */; };
953664F51ECA212100D6D398 /* NutrimentItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 953664F41ECA212100D6D398 /* NutrimentItem.swift */; };
Expand Down Expand Up @@ -302,6 +303,7 @@
9525708B1EE9BC91002FC40D /* CellImageTapable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CellImageTapable.swift; sourceTree = "<group>"; };
9528560A1F78512300863FC6 /* Array.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Array.swift; sourceTree = "<group>"; };
9528560D1F798EAA00863FC6 /* SummaryFormTableViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SummaryFormTableViewControllerTests.swift; sourceTree = "<group>"; };
952C3BE81F9A335F003C755A /* UIViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewController.swift; sourceTree = "<group>"; };
953498F81F76967A00568C35 /* NavigationControllerMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationControllerMock.swift; sourceTree = "<group>"; };
953498FB1F77AFF900568C35 /* ProductDetailViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductDetailViewControllerTests.swift; sourceTree = "<group>"; };
953664F41ECA212100D6D398 /* NutrimentItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NutrimentItem.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1444,6 +1446,7 @@
95E16B2E1EE9E20A00331B2B /* UIStackView.swift */,
95D060DA1F6094D30052012D /* UITableView.swift */,
9528560A1F78512300863FC6 /* Array.swift */,
952C3BE81F9A335F003C755A /* UIViewController.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -2041,6 +2044,7 @@
95781BBE1EC3A898003E3256 /* Product.swift in Sources */,
956FF9661F1FF0FD0069D678 /* SearchTableViewControllerState.swift in Sources */,
95F7DB3E1F98E42500428208 /* UserDefaultsConstants.swift in Sources */,
952C3BE91F9A335F003C755A /* UIViewController.swift in Sources */,
958F33531F378076005269C5 /* InfoRowTableViewCell.swift in Sources */,
957094AF1EA124E800268236 /* ProductService.swift in Sources */,
951FA7881F50C0670096AC5A /* AccessibilityIdentifiers.swift in Sources */,
Expand Down
4 changes: 4 additions & 0 deletions OpenFoodFacts/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@

// Product Detail
"product-detail.header.add-new-picture" = "Add a new picture";
/* Keep this text as short as possible */
"product-detail.edit-alert.title" = "Remember to save your changes";
/* Keep this text as short as possible */
"product-detail.edit-alert.subtitle" = "Scroll down to the 'Save' button";

// Product detail page titles
"product-detail.page-title.summary" = "Summary";
Expand Down
24 changes: 24 additions & 0 deletions OpenFoodFacts/Extensions/UIViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// UIViewController.swift
// OpenFoodFacts
//
// Created by Andrés Pizá Bückmann on 20/10/2017.
// Copyright © 2017 Andrés Pizá Bückmann. All rights reserved.
//

import UIKit
import SafariServices
import NotificationBanner

extension UIViewController {
func openUrlInApp(_ url: URL, showAlert: Bool? = nil) {
let vc = SFSafariViewController(url: url, entersReaderIfAvailable: false)
present(vc, animated: true)

if showAlert == true {
NotificationBanner(title: "product-detail.edit-alert.title".localized,
subtitle: "product-detail.edit-alert.subtitle".localized,
style: .warning).show()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import UIKit
import XLPagerTabStrip
import Crashlytics
import SafariServices

class ProductDetailViewController: ButtonBarPagerTabStripViewController {

Expand Down Expand Up @@ -226,8 +225,7 @@ class ProductDetailViewController: ButtonBarPagerTabStripViewController {

@IBAction func didTapEditButton(_ sender: UIBarButtonItem) {
if let barcode = self.product?.barcode, let url = URL(string: URLs.Edit + barcode) {
let vc = SFSafariViewController(url: url, entersReaderIfAvailable: false)
present(vc, animated: true)
openUrlInApp(url, showAlert: true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

import UIKit
import SafariServices

class SettingsTableViewController: UITableViewController {
@IBOutlet weak var scanOnLaunchSwitch: UISwitch!
Expand Down Expand Up @@ -42,8 +41,7 @@ class SettingsTableViewController: UITableViewController {
}

if let url = url {
let vc = SFSafariViewController(url: url, entersReaderIfAvailable: false)
present(vc, animated: true)
openUrlInApp(url)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

import UIKit
import SafariServices

class LoggedInViewController: ChildViewController {
@IBOutlet weak var usernameLabel: UILabel!
Expand All @@ -27,8 +26,7 @@ class LoggedInViewController: ChildViewController {

@IBAction func didTapYourContributionsButton(_ sender: UIButton) {
if let username = CredentialsController.shared.getUsername(), let url = URL(string: URLs.YourContributions + username) {
let vc = SFSafariViewController(url: url, entersReaderIfAvailable: false)
present(vc, animated: true)
openUrlInApp(url)
}
}
}
4 changes: 1 addition & 3 deletions OpenFoodFacts/ViewControllers/User/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import UIKit
import IQKeyboardManagerSwift
import NotificationBanner
import SafariServices

class LoginViewController: ChildViewController {
@IBOutlet weak var usernameField: UITextField!
Expand Down Expand Up @@ -81,8 +80,7 @@ class LoginViewController: ChildViewController {

@IBAction func didTapCreateAccountButton(_ sender: UIButton) {
if let url = URL(string: URLs.CreateAccount) {
let vc = SFSafariViewController(url: url, entersReaderIfAvailable: false)
present(vc, animated: true)
openUrlInApp(url)
}
}
}

0 comments on commit 371185e

Please sign in to comment.