Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into feature/site-design-…
Browse files Browse the repository at this point in the history
…revamp
  • Loading branch information
twstokes committed May 3, 2022
2 parents 2830846 + 08f36c6 commit 0dc8332
Show file tree
Hide file tree
Showing 331 changed files with 5,783 additions and 1,217 deletions.
6 changes: 3 additions & 3 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def wordpress_ui
end

def wordpress_kit
pod 'WordPressKit', '~> 4.50.0'
pod 'WordPressKit', '~> 4.51.0'
# pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :tag => ''
# pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :branch => 'task/18324-site-creation-with-site-name'
# pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :branch => ''
# pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :commit => ''
# pod 'WordPressKit', :path => '../WordPressKit-iOS'
end
Expand Down Expand Up @@ -169,7 +169,7 @@ abstract_target 'Apps' do
## Gutenberg (React Native)
## =====================
##
gutenberg :tag => 'v1.74.0'
gutenberg :tag => 'v1.75.0'

## Third party libraries
## =====================
Expand Down
204 changes: 102 additions & 102 deletions Podfile.lock

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
19.9
-----


19.8
-----
* [**] Self hosted sites are not restricted by video length during media uploads [https://github.com/wordpress-mobile/WordPress-iOS/pull/18414]
* [*] [internal] My Site Dashboard: Made some changes to the code architecture of the dashboard. The majority of the changes are related to the posts cards. It should have no visible changes but could cause regressions. Please test it by creating/trashing drafts and scheduled posts and testing that they appear correctly on the dashboard. [#18405]
* [*] Quick Start: Updated the Stats tour. The tour can now be accessed from either the dashboard or the menu tab. [#18413]
* [*] Quick Start: Updated the Reader tour. The tour now highlights the Discover tab and guides users to follow topics via the Settings screen. [#18450]
* [*] [internal] Quick Start: Deleted the Edit your homepage tour. [#18469]
* [*] [internal] Quick Start: Refactored some code related to the tasks displayed in the Quick Start Card and the Quick Start modal. It should have no visible changes but could cause regressions. [#18395]
* [**] Follow Conversation flow now enables in-app notifications by default. They were updated to be opt-out rather than opt-in. [#18449]
* [*] Block Editor: Latest Posts block: Add featured image settings [https://github.com/WordPress/gutenberg/pull/39257]
* [*] Block Editor: Prevent incorrect notices displaying when switching between HTML-Visual mode quickly [https://github.com/WordPress/gutenberg/pull/40415]
* [*] Block Editor: Embed block: Fix inline preview cut-off when editing URL [https://github.com/WordPress/gutenberg/pull/35326]
* [*] Block Editor: Prevent gaps shown around floating toolbar when using external keyboard [https://github.com/WordPress/gutenberg/pull/40266]
* [**] We'll now ask users logging in which area of the app they'd like to focus on to build towards a more personalized experience. [#18385]

19.7
-----
Expand Down
41 changes: 41 additions & 0 deletions Scripts/BuildPhases/LintAppLocalizedStringsUsage.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env ruby

require 'xcodeproj'

REPO_ROOT = Pathname.new(__dir__) + '../..'

def lint(file_path:, target_name:)
violations_count = 0
File.foreach(file_path, mode: 'rb:BOM|UTF-8').with_index do |line, line_no|
next if line.match? %r(^\s*//) # Skip commented lines

col_no = line.index('NSLocalizedString')
next if col_no.nil?

puts "#{file_path}:#{line_no+1}:#{col_no+1}: error: Use `AppLocalizedString` instead of `NSLocalizedString` in source files that are used in the `#{target_name}` extension target. See paNNhX-nP-p2 for more info."
violations_count += 1
end
violations_count
end

## Main ##

project = Xcodeproj::Project.open(REPO_ROOT + 'WordPress/WordPress.xcodeproj')
targets_to_analyze = if ARGV.count.positive?
project.targets.select { |t| t.name == ARGV.first }
else
project.targets.select { |t| t.is_a?(Xcodeproj::Project::Object::PBXNativeTarget) && t.extension_target_type? }
end

violations_count = 0
targets_to_analyze.each do |target|
build_phase = target.build_phases.find { |p| p.is_a?(Xcodeproj::Project::Object::PBXSourcesBuildPhase) }
next if build_phase.nil?

puts "Linting extension target #{target.name} for improper NSLocalizedString usage..."
source_files = build_phase.files_references.map(&:real_path).select { |f| ['.m', '.swift'].any? { |ext| f.extname == ext } }
source_files.each { |f| violations_count += lint(file_path: f, target_name: target.name) }
puts "Done."
end

exit 1 if violations_count > 0
27 changes: 27 additions & 0 deletions Scripts/BuildPhases/runRubyScript
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash -eu

# Use this to run a Ruby script from a "Script Build Phase" from Xcode.
#
# Since shell scripts ran by Xcode do not source the user shell profile, typical user setups like the configurations of `rbenv` or `rvm` would not be set up properly.
# This script check if either `rbenv` or `rvm` is installed on the Mac and runs the setup steps as appropriate, before running the ruby script via `bundle exec`
#
# Usage:
# `runRubyScript <script_name.rb> <optional_args>`
#
# Where <script_name.rb` can be either an absolute path, or a path relative to this runRubyScript wrapper script.
#
# Inspiration: https://mgrebenets.github.io/xcode/2019/04/04/xcode-build-phases-and-environment
#

# Add `rbenv` and `rvm` binaries to PATH, so that we support both
export PATH="$HOME/.rbenv/shims:$HOME/.rvm/bin:$PATH"
RUBY_VERSION="$(cat "${PROJECT_DIR}/../.ruby-version")"
if command -v rvm; then
source "$(rvm "${RUBY_VERSION}" do rvm env --path | tail -n1)"
fi

# Run the script with bundle exec
echo "Running the script using 'bundle exec' ..."
cd "$(dirname "${BASH_SOURCE[0]}")"
bundle exec ruby "$@"
cd -
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ public class LastPostStatsRecordValue: StatsRecordValue {
return URL(string: url)
}

public var featuredImageURL: URL? {
guard let url = featuredImageUrlString as String? else {
return nil
}
return URL(string: url)
}

public override func validateForInsert() throws {
try super.validateForInsert()
try recordValueSingleValueValidation()
Expand All @@ -27,6 +34,7 @@ extension StatsLastPostInsight: StatsRecordValueConvertible {
value.urlString = self.url.absoluteString
value.viewsCount = Int64(self.viewsCount)
value.postID = Int64(self.postID)
value.featuredImageUrlString = self.featuredImageURL?.absoluteString

return [value]
}
Expand All @@ -47,7 +55,8 @@ extension StatsLastPostInsight: StatsRecordValueConvertible {
likesCount: Int(insight.likesCount),
commentsCount: Int(insight.commentsCount),
viewsCount: Int(insight.viewsCount),
postID: Int(insight.postID))
postID: Int(insight.postID),
featuredImageURL: insight.featuredImageURL)
}

static var recordType: StatsRecordType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ extension LastPostStatsRecordValue {
@NSManaged public var urlString: String?
@NSManaged public var viewsCount: Int64
@NSManaged public var postID: Int64
@NSManaged public var featuredImageUrlString: String?

}
75 changes: 75 additions & 0 deletions WordPress/Classes/Services/BloggingPromptsService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import CoreData
import WordPressKit

class BloggingPromptsService {
private let context: NSManagedObjectContext
private let siteID: NSNumber
private let remote: BloggingPromptsServiceRemote
private let calendar: Calendar = .autoupdatingCurrent

private var defaultDate: Date {
calendar.date(byAdding: .day, value: -10, to: Date()) ?? Date()
}

/// Fetches a number of blogging prompts starting from the specified date.
/// When no parameters are specified, this method will attempt to return prompts from ten days ago and two weeks ahead.
///
/// - Parameters:
/// - date: When specified, only prompts from the specified date will be returned. Defaults to 10 days ago.
/// - number: The amount of prompts to return. Defaults to 24 when unspecified.
/// - success: Closure to be called when the fetch process succeeded.
/// - failure: Closure to be called when the fetch process failed.
func fetchPrompts(from date: Date? = nil,
number: Int = 24,
success: @escaping ([BloggingPrompt]) -> Void,
failure: @escaping (Error?) -> Void) {
let fromDate = date ?? defaultDate
remote.fetchPrompts(for: siteID, number: number, fromDate: fromDate) { result in
switch result {
case .success(let remotePrompts):
// TODO: Upsert into CoreData once the CoreData model is available.
success(remotePrompts.map { BloggingPrompt(with: $0) })
case .failure(let error):
failure(error)
}
}
}

required init?(context: NSManagedObjectContext = ContextManager.shared.mainContext,
remote: BloggingPromptsServiceRemote? = nil,
blog: Blog? = nil) {
guard let account = AccountService(managedObjectContext: context).defaultWordPressComAccount(),
let siteID = blog?.dotComID ?? account.primaryBlogID else {
return nil
}

self.context = context
self.siteID = siteID
self.remote = remote ?? .init(wordPressComRestApi: account.wordPressComRestV2Api)
}
}

// MARK: - Temporary model object

/// TODO: This is a temporary model to be replaced with Core Data model once the fields have all been finalized.
struct BloggingPrompt {
let promptID: Int
let text: String
let title: String // for post title
let content: String // for post content
let date: Date
let answered: Bool
let answerCount: Int
let displayAvatarURLs: [URL]

init(with remotePrompt: RemoteBloggingPrompt) {
promptID = remotePrompt.promptID
text = remotePrompt.text
title = remotePrompt.title
content = remotePrompt.content
date = remotePrompt.date
answered = remotePrompt.answered
answerCount = remotePrompt.answeredUsersCount
displayAvatarURLs = remotePrompt.answeredUserAvatarURLs
}
}
31 changes: 31 additions & 0 deletions WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import Foundation
case readerChipsMoreToggled
case readerToggleFollowConversation
case readerToggleCommentNotifications
case readerMoreToggleFollowConversation
case readerPostReported
case readerArticleDetailMoreTapped
case readerSharedItem
Expand Down Expand Up @@ -337,6 +338,17 @@ import Foundation

// Quick Start
case quickStartStarted
case quickStartTapped

// Onboarding Question Prompt
case onboardingQuestionsDisplayed
case onboardingQuestionsItemSelected
case onboardingQuestionsSkipped

// Onboarding Enable Notifications Prompt
case onboardingEnableNotificationsDisplayed
case onboardingEnableNotificationsSkipped
case onboardingEnableNotificationsEnableTapped

/// A String that represents the event
var value: String {
Expand Down Expand Up @@ -472,6 +484,8 @@ import Foundation
return "reader_toggle_follow_conversation"
case .readerToggleCommentNotifications:
return "reader_toggle_comment_notifications"
case .readerMoreToggleFollowConversation:
return "reader_more_toggle_follow_conversation"
case .readerPostReported:
return "reader_post_reported"
case .readerArticleDetailMoreTapped:
Expand Down Expand Up @@ -878,6 +892,8 @@ import Foundation
// Quick Start
case .quickStartStarted:
return "quick_start_started"
case .quickStartTapped:
return "quick_start_tapped"

// Site Intent Question
case .enhancedSiteCreationIntentQuestionCanceled:
Expand All @@ -895,6 +911,21 @@ import Foundation
case .enhancedSiteCreationIntentQuestionExperiment:
return "enhanced_site_creation_intent_question_experiment"

// Onboarding Question Prompt
case .onboardingQuestionsDisplayed:
return "onboarding_questions_displayed"
case .onboardingQuestionsItemSelected:
return "onboarding_questions_item_selected"
case .onboardingQuestionsSkipped:
return "onboarding_questions_skipped"

// Onboarding Enable Notifications Prompt
case .onboardingEnableNotificationsDisplayed:
return "onboarding_enable_notifications_displayed"
case .onboardingEnableNotificationsSkipped:
return "onboarding_enable_notifications_skipped"
case .onboardingEnableNotificationsEnableTapped:
return "onboarding_enable_notifications_enable_tapped"
// Site Name
case .enhancedSiteCreationSiteNameCanceled:
return "enhanced_site_creation_site_name_canceled"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public enum NotificationDeletionKind {
public var legendText: String {
switch self {
case .deletion:
return NSLocalizedString("Comment has been deleted", comment: "Displayed when a Comment is deleted")
return AppLocalizedString("Comment has been deleted", comment: "Displayed when a Comment is deleted")
case .spamming:
return NSLocalizedString("Comment has been marked as Spam", comment: "Displayed when a Comment is spammed")
return AppLocalizedString("Comment has been marked as Spam", comment: "Displayed when a Comment is spammed")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ final class BlogDashboardViewController: UIViewController {
} else {
self.collectionView.scrollToTop(animated: true)
}
self.mySiteViewController?.additionalSafeAreaInsets = UIEdgeInsets(top: 0, left: 0, bottom: Constants.bottomPaddingForQuickStartNotices, right: 0)
default:
break
}
Expand Down Expand Up @@ -294,7 +293,6 @@ extension BlogDashboardViewController {
static let horizontalSectionInset: CGFloat = 20
static let verticalSectionInset: CGFloat = 20
static let cellSpacing: CGFloat = 20
static let bottomPaddingForQuickStartNotices: CGFloat = 80
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import UIKit
import WordPressShared

/// Card cell prompting the user to create their first post
final class DashboardFirstPostCardCell: DashboardEmptyPostsCardCell, BlogDashboardCardConfigurable {
Expand Down Expand Up @@ -48,7 +49,7 @@ class DashboardEmptyPostsCardCell: UICollectionViewCell, Reusable {
private lazy var titleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.text = "Create your first post"
titleLabel.font = WPStyleGuide.notoBoldFontForTextStyle(.title3)
titleLabel.font = WPStyleGuide.serifFontForTextStyle(.title3, fontWeight: .semibold)
titleLabel.adjustsFontForContentSizeCategory = true
titleLabel.adjustsFontSizeToFitWidth = true
titleLabel.minimumScaleFactor = 0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ final class AvatarTrainView: UIView {
// redraw border when user interface style changes.
if let previousTraitCollection = previousTraitCollection,
previousTraitCollection.userInterfaceStyle != traitCollection.userInterfaceStyle {
avatarStackView.subviews.forEach { configureBorder(for: $0) }
configureAvatarBorders()
}
}

override func layoutSubviews() {
configureAvatarBorders()
}

}

// MARK: Private Helpers
Expand All @@ -62,7 +66,6 @@ private extension AvatarTrainView {
func makeAvatarImageView(with avatarURL: URL? = nil) -> UIImageView {
let imageView = CircularImageView(image: placeholderImage)
imageView.translatesAutoresizingMaskIntoConstraints = false
configureBorder(for: imageView)

NSLayoutConstraint.activate([
imageView.heightAnchor.constraint(equalToConstant: imageHeight),
Expand All @@ -76,9 +79,12 @@ private extension AvatarTrainView {
return imageView
}

func configureBorder(for view: UIView) {
view.layer.borderWidth = Constants.borderWidth
view.layer.borderColor = UIColor.listForeground.cgColor
func configureAvatarBorders() {
avatarStackView.arrangedSubviews.forEach { view in
view.layer.masksToBounds = true
view.layer.borderWidth = Constants.borderWidth
view.layer.borderColor = UIColor.listForeground.cgColor
}
}

// MARK: Constants
Expand Down
Loading

0 comments on commit 0dc8332

Please sign in to comment.