Skip to content

Commit

Permalink
Build App Menu Bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Yazan98 committed Jan 27, 2024
1 parent a7ad657 commit 17f2832
Show file tree
Hide file tree
Showing 38 changed files with 255 additions and 821 deletions.
24 changes: 24 additions & 0 deletions Tapper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
8AD4A6792B53019900B2F05B /* PickerOptionEntityDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AD4A6782B53019900B2F05B /* PickerOptionEntityDetails.swift */; };
8AD4A67C2B53146C00B2F05B /* DeveloperOptionCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AD4A67B2B53146C00B2F05B /* DeveloperOptionCommand.swift */; };
8AD4A67E2B5317BF00B2F05B /* TestFunctionCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AD4A67D2B5317BF00B2F05B /* TestFunctionCommand.swift */; };
8AF0BBD62B64F0DD00F79B39 /* TapperMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AF0BBD52B64F0DD00F79B39 /* TapperMenu.swift */; };
8AF0BBD82B64F13E00F79B39 /* TapperTopMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AF0BBD72B64F13E00F79B39 /* TapperTopMenuView.swift */; };
8AF0BBDA2B64F25800F79B39 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AF0BBD92B64F25800F79B39 /* AppDelegate.swift */; };
8AF0BBDC2B64F96B00F79B39 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 8AF0BBDB2B64F96B00F79B39 /* Credits.rtf */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -146,6 +150,10 @@
8AD4A6782B53019900B2F05B /* PickerOptionEntityDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickerOptionEntityDetails.swift; sourceTree = "<group>"; };
8AD4A67B2B53146C00B2F05B /* DeveloperOptionCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeveloperOptionCommand.swift; sourceTree = "<group>"; };
8AD4A67D2B5317BF00B2F05B /* TestFunctionCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestFunctionCommand.swift; sourceTree = "<group>"; };
8AF0BBD52B64F0DD00F79B39 /* TapperMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TapperMenu.swift; sourceTree = "<group>"; };
8AF0BBD72B64F13E00F79B39 /* TapperTopMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TapperTopMenuView.swift; sourceTree = "<group>"; };
8AF0BBD92B64F25800F79B39 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
8AF0BBDB2B64F96B00F79B39 /* Credits.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = Credits.rtf; sourceTree = "<group>"; };
C8FD477F3D6ECACDE0E3AEA3 /* Pods-Tapper.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tapper.release.xcconfig"; path = "Target Support Files/Pods-Tapper/Pods-Tapper.release.xcconfig"; sourceTree = "<group>"; };
F26D3965327B582E144E1D51 /* Pods_Tapper.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Tapper.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F76B1AD878E6EF89CDEBCE5F /* Pods-Tapper.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tapper.debug.xcconfig"; path = "Target Support Files/Pods-Tapper/Pods-Tapper.debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -229,6 +237,7 @@
8A9D40CA2B48F123009CB2DB /* Tapper */ = {
isa = PBXGroup;
children = (
8AF0BBD42B64F0D500F79B39 /* Menu */,
8A8CF7BF2B59A50600CD0214 /* Dialogs */,
8AD4A66B2B4F033F00B2F05B /* Info.plist */,
8A9D40F62B49E414009CB2DB /* Database */,
Expand All @@ -242,6 +251,8 @@
8A9D40D12B48F124009CB2DB /* Assets.xcassets */,
8A9D40D62B48F124009CB2DB /* Tapper.entitlements */,
8A9D40D32B48F124009CB2DB /* Preview Content */,
8AF0BBD92B64F25800F79B39 /* AppDelegate.swift */,
8AF0BBDB2B64F96B00F79B39 /* Credits.rtf */,
);
path = Tapper;
sourceTree = "<group>";
Expand Down Expand Up @@ -373,6 +384,15 @@
path = Commands;
sourceTree = "<group>";
};
8AF0BBD42B64F0D500F79B39 /* Menu */ = {
isa = PBXGroup;
children = (
8AF0BBD52B64F0DD00F79B39 /* TapperMenu.swift */,
8AF0BBD72B64F13E00F79B39 /* TapperTopMenuView.swift */,
);
path = Menu;
sourceTree = "<group>";
};
A58F688DE6EC499D0C25998C /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -477,6 +497,7 @@
8A9D40D52B48F124009CB2DB /* Preview Assets.xcassets in Resources */,
8AC7606F2B4BA2C400530BBD /* .gitignore in Resources */,
8A9D40D22B48F124009CB2DB /* Assets.xcassets in Resources */,
8AF0BBDC2B64F96B00F79B39 /* Credits.rtf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -557,9 +578,11 @@
8AD4A66F2B4F03F300B2F05B /* TapperConsts.swift in Sources */,
8AC760652B4B5A3A00530BBD /* HomeStatusBarView.swift in Sources */,
8A9D40EF2B49D534009CB2DB /* HomeViewModel.swift in Sources */,
8AF0BBD82B64F13E00F79B39 /* TapperTopMenuView.swift in Sources */,
8A9D40F52B49DDC1009CB2DB /* TapperCommandView.swift in Sources */,
8AC7606B2B4B813A00530BBD /* ApplicationSettingsDialog.swift in Sources */,
8AC760772B4DFABB00530BBD /* TapperTestScenariosDataSource.swift in Sources */,
8AF0BBDA2B64F25800F79B39 /* AppDelegate.swift in Sources */,
8AC760792B4EF9EE00530BBD /* CreateTestScenarioDialog.swift in Sources */,
8AC760692B4B5D2A00530BBD /* TapperHomeCommandType.swift in Sources */,
8A8CF7BA2B59A13100CD0214 /* TapperTestCommandsDataSource.swift in Sources */,
Expand All @@ -575,6 +598,7 @@
8A8CF7BC2B59A20B00CD0214 /* TapperTestCommandEntity.swift in Sources */,
8AD4A66D2B4F03D400B2F05B /* MonkeyTestingScreen.swift in Sources */,
8A9D40E92B49C214009CB2DB /* SplashScreenNavigationListener.swift in Sources */,
8AF0BBD62B64F0DD00F79B39 /* TapperMenu.swift in Sources */,
8AD4A6772B52F8B300B2F05B /* TapperPickerType.swift in Sources */,
8AC760592B4B57D900530BBD /* HomeScreenContentType.swift in Sources */,
8A9D40E32B48F4EF009CB2DB /* HomeScreen.swift in Sources */,
Expand Down
Binary file not shown.
37 changes: 37 additions & 0 deletions Tapper/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// AppDelegate.swift
// Tapper
//
// Created by Yazan Tarifi on 27/01/2024.
//

import Foundation
import SwiftUI

public final class AppDelegate: NSObject, NSApplicationDelegate {

static private(set) var instance: AppDelegate!
lazy var statusBarItem = NSStatusBar.system.statusItem(withLength: CGFloat(30))
let menu = TapperMenu()

public func applicationDidFinishLaunching(_ notification: Notification) {
AppDelegate.instance = self

if let image = NSImage(named: NSImage.Name("WhiteLogo")) {
// Set the desired width and height
let logoWidth: CGFloat = 24
let logoHeight: CGFloat = 24

// Resize the image
let resizedImage = NSImage(size: NSSize(width: logoWidth, height: logoHeight), flipped: false, drawingHandler: { rect in
image.draw(in: NSRect(origin: .zero, size: NSSize(width: logoWidth, height: logoHeight)))
return true
})

// Assign the resized image to the button
statusBarItem.button?.image = resizedImage
statusBarItem.button?.imagePosition = .imageLeading
statusBarItem.menu = menu.onCreateMenu()
}
}
}
23 changes: 23 additions & 0 deletions Tapper/Assets.xcassets/WhiteLogo.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "New Project Small.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "New Project Small 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "New Project Small 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions Tapper/Credits.rtf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{\rtf1\ansi\ansicpg1252\cocoartf2757
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\qc\partightenfactor0

\f0\fs24 \cf0 Tapper\
Android Development Application Tool\
\
Tapper Built to help Android Developers do ADB Functions Faster also Automated via Desktop Application\
Tapper also an Open Source Application Built and Maintained by @Yazan98 on Github\
Project Website: https://tapperapp.com\
Project Docs: https://docs.tapperapp.com\
Project Source Code: https:.//github.com/tapper-app}
109 changes: 109 additions & 0 deletions Tapper/Menu/TapperMenu.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
//
// TapperMenu.swift
// Tapper
//
// Created by Yazan Tarifi on 27/01/2024.
//

import Foundation
import SwiftUI

public final class TapperMenu: NSObject {

@Environment(\.openURL) var openUrl
private let menu = NSMenu()

public func onCreateMenu() -> NSMenu {
let topView = TapperTopMenuView()
let topViewToInsert = NSHostingController(rootView: topView)
topViewToInsert.view.frame.size = CGSize(width: 300, height: 130)

let topBarMenuItem = NSMenuItem()
topBarMenuItem.view = topViewToInsert.view
menu.addItem(topBarMenuItem)
menu.addItem(NSMenuItem.separator())

let developerOptionsMenuItem = NSMenuItem(
title: "Developer Options",
action: #selector(onClickOnDeveloperOptionsItem),
keyEquivalent: ""
)

let generalOptionsMenuItem = NSMenuItem(
title: "General Options",
action: #selector(onClickOnGeneralOptionsItem),
keyEquivalent: ""
)

let testingOptionsMenuItem = NSMenuItem(
title: "Testing Options",
action: #selector(onClickOnTestingOptionsItem),
keyEquivalent: ""
)

let monkeyTestingOptionsMenuItem = NSMenuItem(
title: "Monkey Testing",
action: #selector(onClickOnMonkeyTestingOptionsItem),
keyEquivalent: ""
)

let aboutApplication = NSMenuItem(
title: "About Tapper",
action: #selector(onAboutClickListener),
keyEquivalent: ""
)

developerOptionsMenuItem.target = self
menu.addItem(developerOptionsMenuItem)

generalOptionsMenuItem.target = self
menu.addItem(generalOptionsMenuItem)

testingOptionsMenuItem.target = self
menu.addItem(testingOptionsMenuItem)

monkeyTestingOptionsMenuItem.target = self
menu.addItem(monkeyTestingOptionsMenuItem)

aboutApplication.target = self
menu.addItem(aboutApplication)

return menu
}

@objc func onClickOnDeveloperOptionsItem(sender: NSMenuItem) {
guard let url = URL(string: "tapper://\(TapperConsts.DEVELOPER_DEEPLINK_KEY)") else {
return
}

openUrl(url)
}

@objc func onClickOnGeneralOptionsItem(sender: NSMenuItem) {
guard let url = URL(string: "tapper://\(TapperConsts.GENERAL_DEEPLINK_KEY)") else {
return
}

openUrl(url)
}

@objc func onClickOnTestingOptionsItem(sender: NSMenuItem) {
guard let url = URL(string: "tapper://\(TapperConsts.TESTING_DEEPLINK_KEY)") else {
return
}

openUrl(url)
}

@objc func onClickOnMonkeyTestingOptionsItem(sender: NSMenuItem) {
guard let url = URL(string: "tapper://\(TapperConsts.MONKEY_TESTING_DEEPLINK_KEY)") else {
return
}

openUrl(url)
}

@objc func onAboutClickListener(sender: NSMenuItem) {
NSApp.orderFrontStandardAboutPanel(sender)
}
}
40 changes: 40 additions & 0 deletions Tapper/Menu/TapperTopMenuView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// TapperTopMenuView.swift
// Tapper
//
// Created by Yazan Tarifi on 27/01/2024.
//

import SwiftUI

struct TapperTopMenuView: View {
var body: some View {
VStack(alignment: .leading) {
VStack(alignment: .leading) {
Image("Logo")
.resizable()
.frame(width: 50, height: 50)
.foregroundColor(TapperUtils.shared.getTextPrimaryColor())


Text("Tapper")
.foregroundColor(TapperUtils.shared.getApplicationPrimaryColor())
.font(.title3)

Text("Android Development Tool")
.foregroundColor(TapperUtils.shared.getRedColor())
.font(.caption)

Text("Automate, Change Developer Options In Your Android Applications Without Writing Code or Commands")
.foregroundColor(TapperUtils.shared.getApplicationSecondColor())
.font(.caption2)
.lineLimit(2)
}
.padding()
}
}
}

#Preview {
TapperTopMenuView()
}
2 changes: 1 addition & 1 deletion Tapper/Screens/MonkeyTestingScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct MonkeyTestingScreen: View {
Text("")
.frame(height: 50)

if !applicationPackageNameExecution.isEmpty {
if applicationPackageNameExecution.isEmpty {
Group {
TextField("Application Package Name *", text: $applicationPackageNameExecution, prompt: Text("Application Package Name *")
.foregroundColor(TapperUtils.shared.getApplicationPrimaryColor()))
Expand Down
7 changes: 6 additions & 1 deletion Tapper/TapperApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct TapperApp: App, SplashScreenNavigationListener {

@State private var isSplashScreenEnd: Bool = false
@State private var applicationPackageNameDeeplink: String = ""
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

var body: some Scene {
WindowGroup("Tapper") {
Expand All @@ -32,7 +33,11 @@ struct TapperApp: App, SplashScreenNavigationListener {
MonkeyTestingScreen(applicationPackageNameExecution: $applicationPackageNameDeeplink)
.frame(minWidth: 450, minHeight: 600)
.onOpenURL{ url in
applicationPackageNameDeeplink = url.absoluteString.replacingOccurrences(of: "tapper://\(TapperConsts.MONKEY_TESTING_DEEPLINK_KEY)/", with: "")
if url.absoluteString.contains(".") {
applicationPackageNameDeeplink = url.absoluteString.replacingOccurrences(of: "tapper://\(TapperConsts.MONKEY_TESTING_DEEPLINK_KEY)/", with: "")
} else {
applicationPackageNameDeeplink = ""
}
}
}
.windowResizability(.contentSize)
Expand Down

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Loading

0 comments on commit 17f2832

Please sign in to comment.