@@ -1,9 +1,10 @@
@import UIKit;
@import WMF.Swift;
#import "WMFOpenExternalLinkDelegateProtocol.h"

@class PaddedLabel;
@protocol PreviewLicenseViewDelegate;
@interface PreviewLicenseView : UIView
@interface PreviewLicenseView : UIView <WMFThemeable>

@property (weak, nonatomic) IBOutlet PaddedLabel *licenseCCLabel;
@property (weak, nonatomic) IBOutlet PaddedLabel *licenseTitleLabel;
@@ -13,13 +13,16 @@ @interface PreviewLicenseView ()
@property (nonatomic) BOOL hideTopDivider;
@property (nonatomic) BOOL hideBottomDivider;

@property (nonatomic, strong) WMFTheme *theme;

@end

@implementation PreviewLicenseView

- (instancetype)initWithCoder:(NSCoder *)coder {
self = [super initWithCoder:coder];
if (self) {
self.theme = [WMFTheme standard];
self.hideTopDivider = YES;
self.hideBottomDivider = YES;
}
@@ -32,7 +35,7 @@ - (void)didMoveToSuperview {
self.licenseTitleLabel.font = [UIFont systemFontOfSize:11.0];
self.licenseLoginLabel.font = [UIFont systemFontOfSize:11.0];

self.licenseTitleLabel.text = WMFLocalizedStringWithDefaultValue(@"wikitext-upload-save-terms-cc-by-sa-and-gdfl", nil, nil, @"By publishing changes, you agree to the %1$@and agree to release your contribution under the %2$@ and %3$@ license.", @"Button text for information about the Terms of Use and edit licenses. Parameters:\n* %1$@ - 'Terms of Use' link ([[Wikimedia:Wikipedia-ios-wikitext-upload-save-terms-name]])\n* %2$@ - license name link 1\n* %3$@ - license name link 2");
self.licenseTitleLabel.text = WMFLocalizedStringWithDefaultValue(@"wikitext-upload-save-terms-cc-by-sa-and-gdfl", nil, nil, @"By publishing changes, you agree to the %1$@ and agree to release your contribution under the %2$@ and %3$@ license.", @"Button text for information about the Terms of Use and edit licenses. Parameters:\n* %1$@ - 'Terms of Use' link ([[Wikimedia:Wikipedia-ios-wikitext-upload-save-terms-name]])\n* %2$@ - license name link 1\n* %3$@ - license name link 2");
[self styleLinks:self.licenseTitleLabel];
[self.licenseTitleLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(termsLicenseLabelTapped:)]];

@@ -68,18 +71,19 @@ - (id)awakeAfterUsingCoder:(NSCoder *)aDecoder {
- (void)styleLinks:(UILabel *)label {
NSDictionary *baseAttributes =
@{
NSForegroundColorAttributeName: label.textColor,
NSFontAttributeName: label.font
NSForegroundColorAttributeName: label.textColor,
NSFontAttributeName: label.font
};

NSDictionary *linkAttributes =
@{
//NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle),
NSForegroundColorAttributeName: [UIColor wmf_blue]
//NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle),
NSForegroundColorAttributeName: self.theme.colors.link
};

label.attributedText = [label.text attributedStringWithAttributes:baseAttributes
substitutionStrings:@[WMFLicenses.localizedSaveTermsTitle, WMFLicenses.localizedCCBYSA3Title, WMFLicenses.localizedGDFLTitle] substitutionAttributes:@[linkAttributes, linkAttributes, linkAttributes]];
substitutionStrings:@[WMFLicenses.localizedSaveTermsTitle, WMFLicenses.localizedCCBYSA3Title, WMFLicenses.localizedGDFLTitle]
substitutionAttributes:@[linkAttributes, linkAttributes, linkAttributes]];
}

- (void)termsLicenseLabelTapped:(UITapGestureRecognizer *)recognizer {
@@ -91,14 +95,14 @@ - (void)termsLicenseLabelTapped:(UITapGestureRecognizer *)recognizer {
- (void)underlineSignIn:(UILabel *)label {
NSDictionary *baseAttributes =
@{
NSForegroundColorAttributeName: label.textColor,
NSFontAttributeName: label.font
NSForegroundColorAttributeName: label.textColor,
NSFontAttributeName: label.font
};

NSDictionary *substitutionAttributes =
@{
NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle),
NSForegroundColorAttributeName: [UIColor wmf_blue]
NSForegroundColorAttributeName: self.theme.colors.link
};

label.attributedText =
@@ -111,9 +115,15 @@ - (NSAttributedString *)getCCIconAttributedString {
return [[NSAttributedString alloc] initWithString:WIKIGLYPH_CC
attributes:@{
NSFontAttributeName: [UIFont wmf_glyphFontOfSize:42.0],
NSForegroundColorAttributeName: [UIColor wmf_blue],
NSForegroundColorAttributeName: self.theme.colors.link,
NSBaselineOffsetAttributeName: @1.5
}];
}

#pragma mark - WMFThemeable

- (void)applyTheme:(WMFTheme *)theme {
self.theme = theme;
self.backgroundColor = theme.colors.paperBackground;
}
@end
@@ -18,6 +18,7 @@ @interface SectionEditorViewController () <PreviewAndSaveViewControllerDelegate>
@property (strong, nonatomic) NSString *unmodifiedWikiText;
@property (nonatomic) CGRect viewKeyboardRect;
@property (strong, nonatomic) UIBarButtonItem *rightButton;
@property (strong, nonatomic) WMFTheme *theme;

@end

@@ -30,7 +31,11 @@ - (BOOL)prefersStatusBarHidden {
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.


if (!self.theme) {
self.theme = [WMFTheme standard];
}

[self.navigationController setNavigationBarHidden:NO animated:NO];

UIBarButtonItem *buttonX = [UIBarButtonItem wmf_buttonType:WMFButtonTypeX target:self action:@selector(xButtonPressed)];
@@ -60,6 +65,8 @@ - (void)viewDidLoad {
}

self.viewKeyboardRect = CGRectNull;

[self applyTheme:self.theme];
}

- (void)xButtonPressed {
@@ -185,6 +192,7 @@ - (NSAttributedString *)getAttributedString:(NSString *)string {
attributes:@{
NSParagraphStyleAttributeName: paragraphStyle,
NSFontAttributeName: EDIT_TEXT_VIEW_FONT,
NSForegroundColorAttributeName: self.theme.colors.primaryText
}];
}

@@ -195,6 +203,7 @@ - (void)preview {
previewVC.funnel = self.funnel;
previewVC.savedPagesFunnel = self.savedPagesFunnel;
previewVC.delegate = self;
[previewVC applyTheme: self.theme];
[self.navigationController pushViewController:previewVC animated:YES];
}

@@ -292,11 +301,16 @@ - (BOOL)accessibilityPerformEscape {
return YES;
}


#pragma mark WMFThemeable

- (void)applyTheme:(WMFTheme *)theme {

self.theme = theme;
if (self.viewIfLoaded == nil) {
return;
}
self.editTextView.backgroundColor = theme.colors.paperBackground;
self.editTextView.textColor = theme.colors.primaryText;
self.view.backgroundColor = theme.colors.paperBackground;
}

@end
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="5er-xi-5lN">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="5er-xi-5lN">
<dependencies>
<deployment identifier="iOS"/>
<development version="5100" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Section Editor View Controller-->
@@ -15,17 +15,17 @@
<viewControllerLayoutGuide type="bottom" id="itb-4E-TzB"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Cex-zA-X93">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="ohj-LA-82c">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<color key="backgroundColor" red="0.98039215690000003" green="0.98039215690000003" blue="0.98039215690000003" alpha="1" colorSpace="calibratedRGB"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<color key="backgroundColor" red="0.98039215690000003" green="0.98039215690000003" blue="0.98039215690000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<textInputTraits key="textInputTraits" autocorrectionType="no"/>
</textView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="ohj-LA-82c" firstAttribute="leading" secondItem="Cex-zA-X93" secondAttribute="leading" id="GW3-Ua-a8X"/>
<constraint firstItem="ohj-LA-82c" firstAttribute="top" secondItem="Cex-zA-X93" secondAttribute="top" id="NPC-TM-Xq1"/>
@@ -13,6 +13,7 @@ open class WMFTableOfContentsAnimator: UIPercentDrivenInteractiveTransition, UIV
fileprivate var theme = Theme.standard
public func apply(theme: Theme) {
self.theme = theme
self.presentationController?.apply(theme: theme)
}

var displaySide = WMFTableOfContentsDisplaySide.left
@@ -52,6 +53,9 @@ open class WMFTableOfContentsAnimator: UIPercentDrivenInteractiveTransition, UIV
}

// MARK: - UIViewControllerTransitioningDelegate
weak var presentationController: WMFTableOfContentsPresentationController?

open func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
guard presented == self.presentedViewController else {
return nil
@@ -60,6 +64,7 @@ open class WMFTableOfContentsAnimator: UIPercentDrivenInteractiveTransition, UIV
presentationController.apply(theme: theme)
presentationController.displayMode = displayMode
presentationController.displaySide = displaySide
self.presentationController = presentationController
return presentationController
}

@@ -32,19 +32,14 @@ open class WMFTableOfContentsPresentationController: UIPresentationController, T


lazy var statusBarBackground: UIView = {
let view = UIView(frame: CGRect(x: self.containerView!.bounds.minX, y: self.containerView!.bounds.minY, width: self.containerView!.bounds.width, height: self.statusBarEstimatedHeight))
let view = UIView(frame: CGRect.zero)
view.autoresizingMask = .flexibleWidth
self.statusBarBackgroundBottomBorder.frame = CGRect(x: view.bounds.minX, y: view.bounds.maxY, width: view.bounds.width, height: 0.5)
view.addSubview(self.statusBarBackgroundBottomBorder)
view.layer.shadowOpacity = 0.8
view.layer.shadowOffset = CGSize(width: 0, height: 5)
view.clipsToBounds = false
return view
}()

lazy var statusBarBackgroundBottomBorder: UIView = {
let statusBarBackgroundBottomBorder = UIView(frame: .zero)
statusBarBackgroundBottomBorder.autoresizingMask = .flexibleWidth
return statusBarBackgroundBottomBorder
}()

lazy var closeButton:UIButton = {
let button = UIButton(frame: CGRect.zero)

@@ -97,7 +92,7 @@ open class WMFTableOfContentsPresentationController: UIPresentationController, T


func didTap(_ tap: UITapGestureRecognizer) {
self.tapDelegate?.tableOfContentsPresentationControllerDidTapBackground(self);
self.tapDelegate?.tableOfContentsPresentationControllerDidTapBackground(self)
}

// MARK: - Accessibility
@@ -107,42 +102,28 @@ open class WMFTableOfContentsPresentationController: UIPresentationController, T

// MARK: - UIPresentationController
override open func presentationTransitionWillBegin() {
apply(theme: self.theme)
guard let containerView = self.containerView, let presentedView = self.presentedView else {
return
}

// Add the dimming view and the presented view to the heirarchy
self.backgroundView.frame = self.containerView!.bounds
self.containerView!.addSubview(self.backgroundView)
self.backgroundView.frame = containerView.bounds
self.statusBarBackground.frame = CGRect(x: self.backgroundView.bounds.minX, y: self.backgroundView.bounds.minY, width: self.backgroundView.bounds.width, height: self.statusBarEstimatedHeight)

containerView.addSubview(self.backgroundView)

if(self.traitCollection.verticalSizeClass == .compact){
self.statusBarBackground.isHidden = true
}

updateButtonConstraints()

self.containerView!.addSubview(self.presentedView!)
containerView.addSubview(presentedView)

// Hide the presenting view controller for accessibility
self.togglePresentingViewControllerAccessibility(false)

switch displaySide {
case .center:
self.presentedView?.layer.cornerRadius = 10
self.presentedView?.clipsToBounds = true
self.presentedView?.layer.borderColor = theme.colors.border.cgColor
self.presentedView?.layer.borderWidth = 1.0
self.closeButton.setImage(UIImage(named: "toc-close-blue"), for: UIControlState())
self.closeButton.tintColor = theme.colors.link
self.statusBarBackground.isHidden = true
break
default:
//Add shadow to the presented view
self.presentedView?.layer.shadowOpacity = 0.8
self.presentedView?.layer.shadowColor = self.theme.colors.shadow.cgColor
self.presentedView?.layer.shadowOffset = CGSize(width: 3, height: 5)
self.presentedView?.clipsToBounds = false
self.closeButton.setImage(UIImage(named: "close"), for: UIControlState())
self.statusBarBackground.isHidden = false
}
apply(theme: theme)

// Fade in the dimming view alongside the transition
if let transitionCoordinator = self.presentingViewController.transitionCoordinator {
@@ -183,15 +164,16 @@ open class WMFTableOfContentsPresentationController: UIPresentationController, T
}

override open var frameOfPresentedViewInContainerView : CGRect {
var frame = self.containerView!.bounds;
var frame = self.containerView!.bounds
var bgWidth = self.minimumVisibleBackgroundWidth
var tocWidth = frame.size.width - bgWidth
if(tocWidth > self.maximumTableOfContentsWidth){
tocWidth = self.maximumTableOfContentsWidth
bgWidth = frame.size.width - tocWidth
}

frame.origin.y = UIApplication.shared.statusBarFrame.size.height + 0.5;
frame.origin.y = UIApplication.shared.statusBarFrame.size.height + 0.5
frame.size.height -= frame.origin.y

switch displaySide {
case .center:
@@ -229,13 +211,13 @@ open class WMFTableOfContentsPresentationController: UIPresentationController, T

if newCollection.verticalSizeClass == .compact
{
self.statusBarBackground.isHidden = true;
self.statusBarBackground.isHidden = true

}

if newCollection.verticalSizeClass == .regular
{
self.statusBarBackground.isHidden = false;
self.statusBarBackground.isHidden = false
}

coordinator.animate(alongsideTransition: {(context: UIViewControllerTransitionCoordinatorContext!) -> Void in
@@ -250,9 +232,32 @@ open class WMFTableOfContentsPresentationController: UIPresentationController, T
guard self.containerView != nil else {
return
}

switch displaySide {
case .center:
self.presentedView?.layer.cornerRadius = 10
self.presentedView?.clipsToBounds = true
self.presentedView?.layer.borderColor = theme.colors.border.cgColor
self.presentedView?.layer.borderWidth = 1.0
self.closeButton.setImage(UIImage(named: "toc-close-blue"), for: UIControlState())
self.closeButton.tintColor = theme.colors.link
self.statusBarBackground.isHidden = true
break
default:
//Add shadow to the presented view
self.presentedView?.layer.shadowOpacity = 0.8
self.presentedView?.layer.shadowColor = theme.colors.shadow.cgColor
self.presentedView?.layer.shadowOffset = CGSize(width: 3, height: 5)
self.presentedView?.clipsToBounds = false
self.closeButton.setImage(UIImage(named: "close"), for: UIControlState())
self.statusBarBackground.isHidden = false
}

self.backgroundView.effect = UIBlurEffect(style: theme.blurEffectStyle)
self.statusBarBackgroundBottomBorder.backgroundColor = theme.colors.border

self.statusBarBackground.backgroundColor = theme.colors.paperBackground
self.statusBarBackground.layer.shadowColor = theme.colors.shadow.cgColor

self.closeButton.tintColor = theme.colors.primaryText
}
}
@@ -336,5 +336,8 @@ class WMFTwoFactorPasswordViewController: WMFScrollViewController, UITextFieldDe

titleLabel.textColor = theme.colors.primaryText
tokenLabel.textColor = theme.colors.secondaryText

displayModeToggle.textColor = theme.colors.link
subTitleLabel.textColor = theme.colors.secondaryText
}
}
@@ -373,7 +373,7 @@
"wikitext-upload-save" = "Publishing...";
"wikitext-upload-save-anonymously-warning" = "Edits will be attributed to the IP address of your device. If you $1 you will have more privacy.";
"wikitext-upload-save-sign-in" = "Log in";
"wikitext-upload-save-terms-cc-by-sa-and-gdfl" = "By publishing changes, you agree to the $1and agree to release your contribution under the $2 and $3 license.";
"wikitext-upload-save-terms-cc-by-sa-and-gdfl" = "By publishing changes, you agree to the $1 and agree to release your contribution under the $2 and $3 license.";
"wikitext-upload-save-terms-name" = "Terms of Use";
"zero-charged-verbiage" = "Wikipedia Zero is off";
"zero-charged-verbiage-extended" = "Loading other articles may incur data charges. Saved articles stored offline do not use data and are free.";
Binary file not shown.